Graphics, Figures & TablesVertical lines breaking in table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Robert270706
Posts: 3
Joined: Thu Apr 04, 2024 9:07 am

Vertical lines breaking in table

Post by Robert270706 »

Hi there
I am trying to make a table where "Kriterier" (which means Criteria) and "Ideer" (which means Ideas) to be on seperate lines inside the same box and point toward the row besides it and the column down under respectively.
But when i do the vertical lines break at the top for some reason

This is my latex and also the command "\textrarrow" is just an enclosed rightarrow i have created as a command

Code: Select all

\begin{table}[h]
\centering
\begin{tabular}{ |p{4cm}||p{3cm}|p{3cm}|p{3cm}|  }
 \hline
 \multicolumn{4}{|c|}{Idesi} \\
 \hline
 Kriterier \textrarrow  \\ Ideer $\downarrow$ & ISO ALPHA 2 Code &ISO ALPHA 3 Code&ISO numeric Code\\
 \hline
 Afghanistan   & AF    &AFG&   004\\
 Aland Islands&   AX  & ALA   &248\\
 Albania &AL & ALB&  008\\
 Algeria    &DZ & DZA&  012\\
 American Samoa&   AS  & ASM&016\\
 Andorra& AD  & AND   &020\\
 Angola& AO  & AGO&024\\
 \hline
\end{tabular}
\end{table}
Is there anyway to make the vertical lines connect at the top and still keep Criterias and Ideas on seperate lines?
Last edited by Stefan Kottwitz on Thu Apr 18, 2024 9:50 am, edited 1 time in total.
Reason: code marked

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Vertical lines breaking in table

Post by Stefan Kottwitz »

Hi Robert,

the line was ended right after "Kriterier". you can change it this way, filling it up to the end:

Code: Select all

Kriterier \textrarrow & \multicolumn{3}{c|}{} \\
Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Vertical lines breaking in table

Post by Stefan Kottwitz »

By the way, p columns use full justification, so the cell's content can look a bit stretched. You could make it flushleft/raggedright like the following, using the array package:

Code: Select all

\documentclass[a4paper,14pt,oneside]{article}
\usepackage{textcomp}
\usepackage{array}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{ |p{4cm}|*3{|>{\raggedright\arraybackslash}p{3cm}|} }
\hline
\multicolumn{4}{|c|}{Idesi} \\
\hline
Kriterier \textrightarrow & \multicolumn{3}{c|}{} \\
Ideer $\downarrow$ & ISO ALPHA 2 Code &ISO ALPHA 3 Code&ISO numeric Code\\
\hline
Afghanistan & AF &AFG& 004\\
Aland Islands& AX & ALA &248\\
Albania &AL & ALB& 008\\
Algeria &DZ & DZA& 012\\
American Samoa& AS & ASM&016\\
Andorra& AD & AND &020\\
Angola& AO & AGO&024\\
\hline
\end{tabular}
\end{table}
\end{document}
Stefan
LaTeX.org admin
Robert270706
Posts: 3
Joined: Thu Apr 04, 2024 9:07 am

Vertical lines breaking in table

Post by Robert270706 »

Thank you but the 3rd and 4th vertical line still doesnt go all the way up. Is there anyway to fix this?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Vertical lines breaking in table

Post by Stefan Kottwitz »

Ok, I saw the obvious gap at the right side, that's why my suggestion, but you can easily use & column separators so you have enough empty cells with borders:

Code: Select all

Kriterier \textrarrow & & & \\
Stefan
LaTeX.org admin
FPantigny
Posts: 5
Joined: Wed Jul 26, 2023 10:37 pm

Vertical lines breaking in table

Post by FPantigny »

For information, here is a way to create that table with {NiceTabular} of nicematrix. In this environment, the vertical rules are drawn even if the row is incomplete.

Code: Select all

\documentclass[a4paper,14pt,oneside]{article}
\usepackage{nicematrix}

\begin{document}
\begin{table}[h]
\centering
\begin{NiceTabular}{ |p{4cm}*3{||p[l]{3cm}}|}
\Hline
\Block{1-4}{Idesi} \\
\Hline
Kriterier \textrightarrow \\
Ideer $\downarrow$ & ISO ALPHA 2 Code &ISO ALPHA 3 Code&ISO numeric Code\\
\Hline
Afghanistan & AF &AFG& 004\\
Aland Islands& AX & ALA &248\\
Albania &AL & ALB& 008\\
Algeria &DZ & DZA& 012\\
American Samoa& AS & ASM&016\\
Andorra& AD & AND &020\\
Angola& AO & AGO&024\\
\Hline
\end{NiceTabular}
\end{table}
\end{document}
Post Reply