The \vline
command is employed to draw a vertical line within a tabular
or array
environment, extending across the entire height and depth of a row’s entry. It can also be utilized in an @-expression, although its synonymous counterpart, the vertical bar|
, is more commonly used. It’s important to note that \vline
command is seldom used directly within the body of a table.
Usage of ‘\vline’ command
Consider the following example in which \vline
is used.
\documentclass{article}
\begin{document}
\begin{tabular}{ccc}
\hline
Column 1 & Column 2 & Column 3 \\
\hline
\vline Row 1 & Row 1 & Row 1 \\
Row 2 & Row 2 \vline & Row 2 \\
\hline
\end{tabular}
\end{document}
Output
We have used \vline
before the first cell element in the first row and after the second cell element in the second row. It draws a vertical line. The problem associated with \vline
command is that it is not visually appealing. The vertical line appears just close to the element. This results in an uneven appearance of the table. Alternatively, we can use |
instead of \vline
. For example
documentclass{article}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
Column 1 & Column 2 & Column 3 \\
\hline
Row 1 & Row 1 & Row 1 \\
Row 2 & Row 2 & Row 2 \\
\hline
\end{tabular}
\end{document}
Output
The above example shows that |
is used to draw vertical lines in a table. You can customize \begin{tabular}{|c|c|c|}
depending on your usage. It ensured a consistent and visually appealing appearance of the table.
Important Tip
It is highly recommended to refrain from using vertical lines in tables. While lines can be beneficial in subtly organizing information, they should not hinder the readability of the content. Strive for a design where lines serve as supportive elements, contributing to clarity rather than introducing complexity that may impede a smooth reading experience. You can use the booktabs
package to create good-looking tables.