TeX - LaTeX Asked by Andrea Bustos on June 22, 2021
So, I’m trying to write a Table with some information and for the first time in my life im using multirow and multicolumn. Everything was going kind of ok until I decided to use hline
and, as you can see in the code, one of the horizontal lines is going through a multicolumn and writing over my text.
Can someone tell me how I can prevent this from happening?
begin{table}[]
begin{tabular}{|c|c|c|}
hline
multicolumn{2}{|c|}{textbf{Item}} & textbf{CPU33} hline
multicolumn{2}{|c|}{Dimensiones} & A hline
multicolumn{2}{|c|}{Consumo} & B hline
multirow{4}{*}{Ambiente de operación} & Temperatura & C hline
& Ruido & D hline
& Vibración & E hline
& Schock & F hline
end{tabular}
end{table}
You can use the cline command to draw horizontal line in only two cells. As the code is shown below:
documentclass{article}
usepackage{multirow}
begin{document}
begin{table}
begin{tabular}{|c|c|c|}
hline
multicolumn{2}{|c|}{textbf{Item}} & textbf{CPU33} hline
multicolumn{2}{|c|}{Dimensiones} & A hline
multicolumn{2}{|c|}{Consumo} & B hline
multirow{4}{*}{Ambiente de operación} & Temperatura & C cline{2-3}
& Ruido & D cline{2-3}
& Vibración & E cline{2-3}
& Schock & F hline
end{tabular}
end{table}
end{document}
You can also refer to the following link How can I draw a horizontal line spanning only some of the table cells?
Answered by Abuzar Ghafari on June 22, 2021
In order to make sure a horizontal line does not cross a multirow
cell, you can use cline
instead of hline
. Specify which columns your line should appear in.
Additionally, I have added the cellspace
package in order to allow for a small vertical white space above and below of the text in each cell. In the third example, I also included a table using no vertical lines, no multirow
and just a fex horizontal lines from the booktabs
package:
documentclass{article}
usepackage[column=0]{cellspace}
setlength{cellspacetoplimit}{3pt}
setlength{cellspacebottomlimit}{cellspacetoplimit}
usepackage{multirow}
usepackage{booktabs} % only used in third example
begin{document}
begin{table}
begin{tabular}{|0c|0c|0c|}
hline
multicolumn{2}{|0c|}{textbf{Item}} & textbf{CPU33} hline
multicolumn{2}{|0c|}{Dimensiones} & A hline
multicolumn{2}{|0c|}{Consumo} & B hline
multirow{4.25}{*}{Ambiente de operación} & Temperatura & C cline{2-3}
& Ruido & D cline{2-3}
& Vibración & E cline{2-3}
& Schock & F hline
end{tabular}
end{table}
begin{table}
begin{tabular}{|0c|0c|0c|}
hline
multicolumn{2}{|0c|}{textbf{Item}} & textbf{CPU33} hline
multicolumn{2}{|0c|}{Dimensiones} & A hline
multicolumn{2}{|0c|}{Consumo} & B hline
multirow{4.25}{2cm}{Ambiente de operación} & Temperatura & C cline{2-3}
& Ruido & D cline{2-3}
& Vibración & E cline{2-3}
& Schock & F hline
end{tabular}
end{table}
begin{table}
begin{tabular}{lc}
toprule
Item & CPU33
midrule
Dimensiones & A
Consumo & B
Ambiente de operación
quad Temperatura & C
quad Ruido & D
quad Vibración & E
quad Schock & F
bottomrule
end{tabular}
end{table}
end{document}
Answered by leandriis on June 22, 2021
You can easily make that table with {NiceTabular}
of nicematrix
. The key hvlines
draws all the rules excepted in the blocks (created by Block
).
documentclass{article}
usepackage{nicematrix}
NiceMatrixOptions{cell-space-bottom-limit=3pt,cell-space-top-limit=3pt}
begin{document}
begin{table}
begin{NiceTabular}{lcc}[hvlines]
Block{1-2}{textbf{Item}} & & textbf{CPU33}
Block{1-2}{Dimensiones} & & A
Block{1-2}{Consumo} & & B
Block{4-1}{Ambiente de operación} & Temperatura & C
& Ruido & D
& Vibración & E
& Schock & F
end{NiceTabular}
end{table}
end{document}
You need several compilations.
Answered by F. Pantigny on June 22, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP