how can I draw a vertical line between two specific columns in multicol environment

Trying to have a vertical line between the 4th and the 5th column in a multicol environment.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage{lipsum}
%opening

\begin{document}

\begin{multicols}{5}

\lipsum
%... line_beween_forth_and_fith_column
\end{multicols}

\end{document}

• I'm not really sure what you want, looks like you try to reinvent the wheel. Why don't you use \begin{tabular}{cccc|c} this way you get a table with a line between the 4th and 5th column
– Rico
Sep 1, 2013 at 13:53

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage{lipsum}
%opening

\makeatletter
\setlength\columnseprule{.5pt}

\def\columnseprulecolor\vrule\@width{%
\ifnum\count@=\numexpr\mult@rightbox+8\relax
\vrule\@width
\else
\kern
\fi
}
\makeatother

\begin{document}

\begin{multicols}{5}

\lipsum
%... line_beween_forth_and_fith_column
\end{multicols}

\end{document}

• Using a delimited macro to patch is sneaky :-) and perhaps stating how the 8 comes about might help. Sep 2, 2013 at 6:42
• looks great, but could you explain the macro? Sep 4, 2013 at 12:08
• @user30424 in the depths of multicol is the code sequence \columnseprulecolor\vrule\@width\columnseprule which draws a rule default width 0) of the specified color (default black) by setting the rule width to .5pt rules appear but I abuse \columseprulecolor to test the column number and replace the rule by a kern (horizontal space) except for the specified column. The relevant counter changes by 2 each time starting at \mult@rightbox hence the +8 for column 4 This might not be a fully documented interface in Frank's code but it works well enough here. Sep 4, 2013 at 12:15