5

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}
1
  • 2
    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

1 Answer 1

5

enter image description here

\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}
3
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.