4

How should I do to have vertical line only between the second and the third column? Thank you.

\documentclass{book}

\usepackage{blindtext}

\usepackage{paracol}
\setlength{\columnseprule}{1pt} 
\setcolumnwidth{0.30\textwidth, 0.30\textwidth,, 0.30\textwidth}
\setlength\columnsep{20pt}  

\begin{document}

    \begin{paracol}{3}
    \sloppy
        \switchcolumn[0]
        \blindtext[1]
        \switchcolumn[1]
        \blindtext[1]
         \switchcolumn[2]
        \blindtext[1]
    \end{paracol}

\end{document}
  • Try\setlength{\columnseprule}{0.5pt}. This also works with twocolumn and multicols. – John Kormylo Feb 19 '20 at 15:23
  • Unfortunately, it makes vertical line between the first and the second column and also between the second and the third column. I want only the second one. The space between the first and the second column must be without the vertical line. – Radomir81 Feb 20 '20 at 08:51

1 Answers1

4

This solution uses the everypage package, assuming you want the line on every page.

\documentclass{book}

\usepackage{blindtext}

\usepackage{paracol}
\setcolumnwidth{0.30\textwidth, 0.30\textwidth,, 0.30\textwidth}
\setlength\columnsep{20pt}  

\newlength{\myoffset}
\setlength{\myoffset}{\dimexpr 0.6\textwidth + 1.5\columnsep}

\newcommand{\myhook}% cursor is at (1in,1in) and must not be moved.
{\rlap{\ifodd\value{page}\relax
    \hskip\oddsidemargin \else \hskip\evensidepargin \fi
  \hskip\myoffset\raisebox{\dimexpr-\topmargin-\headheight-\headsep-\textheight}[0pt][0pt]%
{\rule{0.5pt}{\textheight}}}}

\usepackage{everypage}
\AddEverypageHook{\myhook}% Note: you can also use \AddThispageHook, or use tikzpagenodes

\begin{document}

    \begin{paracol}{3}
    \sloppy
        \switchcolumn[0]
        \blindtext[1]
        \switchcolumn[1]
        \blindtext[1]
         \switchcolumn[2]
        \blindtext[1]
    \end{paracol}

\end{document}

This version uses a \tikzmark to locate the top of the paracol. One could also use (current page text area.north west) if starting at the top of the page.

Interestingly, placing the \tikzmark above the paracol doesn't work.

While both the \tikzmark and tikzpicture are invisible, they are equivalent to \hbox{} and will cause a blank line if followed by \switchcolumn.

\documentclass{book}

\usepackage{blindtext}

\usepackage{paracol}
\setcolumnwidth{0.30\textwidth, 0.30\textwidth,, 0.30\textwidth}
\setlength\columnsep{20pt}  

\usepackage{tikzpagenodes}
\usetikzlibrary{tikzmark,calc}

\begin{document}

    \begin{paracol}{3}
    \sloppy
        \switchcolumn[0]
        \noindent\tikzmark{top}\indent
        \blindtext[1]
        \switchcolumn[1]
        \blindtext[1]
        \switchcolumn[2]
        \blindtext[1]
    \end{paracol}
\noindent\begin{tikzpicture}[overlay,remember picture]
  \draw ($(pic cs:top)+(0.6\textwidth+1.5\columnsep, \ht\strutbox)$) --
    (0.6\textwidth+1.5\columnsep, \ht\strutbox);
\end{tikzpicture}

\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120