0

I wound up answering my own question while working on the MWE, but the result was interesting. Perhaps I should rename the question "Why does \columnsep=0pt give me an error when I reset paracol?"

Basically, I can easily switch between \begin{paracol}{4} and \begin{paracol{3} until I use \setcolumnwidth at which point I have to change it every time. I tried using \setcolumnwidth{} and got an error. But when I added it to my MWE, it worked!

It turns out that the error only occurs if you set \columnsep=0pt.

\documentclass{article}
\usepackage{paracol}
\parindent=0pt
\begin{document}

\begin{paracol}{4}
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\end{paracol}

\begin{paracol}{3}
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\end{paracol}

\setcolumnwidth{\dimexpr 0.25\textwidth-0.75\columnsep}% set globally
\begin{paracol}{2}
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\switchcolumn
\end{paracol}%
\setcolumnwidth{}% rset column widths

\begin{paracol}{3}
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\end{paracol}
should match second row

\setlength{\columnsep}{0pt}
\setcolumnwidth{0.25\textwidth}% set globally
\begin{paracol}{2}
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\switchcolumn
\end{paracol}%
\setcolumnwidth{}

Will get error here
\begin{paracol}{3}
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\switchcolumn
\rule{\columnwidth}{1ex}
\end{paracol}

\end{document}

demo

3
  • In case you are wondering what sort of document I was working on. see elfsoft2000.com/chess/3801-3900.pdf (I only add 2 puzzles/day). Commented Aug 23, 2021 at 17:53
  • The package itself uses \columnratio{}\relax to initialize the setting, hence I guess it is safer than \setcolumnwidth{}. Another guess is, the 1sp in \ifdim\@tempdima=\z@ \@tempdima1sp\relax\fi, \pcol@setcw@calcf is too small. 1pt seems to work but is this too large? (1pt = 65,536sp). Commented Aug 27, 2021 at 0:10
  • @muzimuzhiZ - Truth is, I was mostly using \columnsep=0pt just to so I could use 0.25\textwidth instead of \dimexpr 0.25\textwidth-0.75\columnsep. Now I set \columnsidth=1pt and ignore the fact the 0.25\textwidth is 0.75pt too wide. Commented Aug 27, 2021 at 0:15

1 Answer 1

0

Adding a few colors helps clarify the problem.

Even setting \columnnsep to a very small value to avoid the overflow error in the calculations of the column and gap width (see the manual, section 7.3 for the details), the result is wrong: the green line is missing, as you can see from the last line.

The conflict is caused by setting \setcolumnwidth{0pt} to reset the width of the columns, which is not necessary.

Responding to the title of your question:

The setting of column width by the command takes effect in the paracol environments following the command. Therefore, though placing the command in the preamble is the most natural way, you may place this command between two paracol environments to change the column layout for the second one, even when they appear in a page.

In conclusion, \columnnsep = 0pt does not throw any error.

b

\documentclass[12pt]{article}
\usepackage{paracol}

\usepackage{xcolor}
\parindent=0pt

\begin{document}
    
{\Large New code}
    
\begin{paracol}{4}
    \color{green}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{red}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{blue}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{black}\rule{\columnwidth}{1ex}
\end{paracol}

\begin{paracol}{3}
    \color{green}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{red}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{blue}\rule{\columnwidth}{1ex}
\end{paracol}

\bigskip

\setcolumnwidth{\dimexpr 0.25\textwidth-0.75\columnsep}% set globally
\begin{paracol}{2}
    \color{green}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{red}\rule{\columnwidth}{1ex}
\end{paracol}%

%   \setcolumnwidth{0pt}% rset column widths WRONG <<<<<<<<<<<<<<<<

\begin{paracol}{3}
    \color{green}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{red} \rule{\columnwidth}{1ex}
    \switchcolumn
    \color{blue}\rule{\columnwidth}{1ex}
\end{paracol}

\bigskip

Should match second row with no column separations (YES)

\setcolumnwidth{0.25\textwidth}% set globally
    
\setlength{\columnsep}{0pt} % is OK <<<
    
\begin{paracol}{2}      
    \color{green}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{red}\rule{\columnwidth}{1ex}
\end{paracol}%

%   \setcolumnwidth{0pt} % reset column widths WRONG  <<<<<<<<<<<<<

With columnsep =0pt we will get error here (NO)
\begin{paracol}{3}
    \color{green}\rule{\columnwidth}{1ex}
    \switchcolumn           
    \color{red}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{blue}\rule{\columnwidth}{1ex}
\end{paracol}


\vspace*{50pt}

{\Large Former code}


Should match second row with no column separations

 (Does not happens: missing green rule)


\setcolumnwidth{0.25\textwidth}% set globally

\setlength{\columnsep}{0.02pt}  % OK <<<

\begin{paracol}{2}      
    \color{green}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{red}\rule{\columnwidth}{1ex}
\end{paracol}%

\setcolumnwidth{0pt} % rset column widths WRONG <<<<<

Will get error here (only if columnsep=0pt,

 but wrong result anyway, even if columnsep=0.02pt)
\begin{paracol}{3}
    \color{green}\rule{\columnwidth}{1ex}
    \switchcolumn           
    \color{red}\rule{\columnwidth}{1ex}
    \switchcolumn
    \color{blue}\rule{\columnwidth}{1ex}
\end{paracol}

\end{document}
1
  • \setcolumnwidth{} and \setcolumnwidth{0pt} are completely different in effect. Commented Jul 28, 2021 at 0:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .