Paracol:如何仅更改 3 列的样式?

Paracol:如何仅更改 3 列的样式?

在我的文档中,我使用了 2 列和 3 列。我只想使用 更改 3 列的宽度\setcolumnwith{}。2 列应该不受影响。

\documentclass[parskip=full]{scrartcl}

\usepackage{blindtext}

\usepackage{paracol}

\begin{document}

  \begin{paracol}{2} % this is what I want
      \Blindtext[1]
    \switchcolumn
      \Blindtext[1]
  \end{paracol}

\setcolumnwidth{2cm,3cm,4cm} % this should only affect the 3 column

  \begin{paracol}{3} % this is what I want
      \blindtext
    \switchcolumn[1]
      \blindtext
    \switchcolumn[2]
      \blindtext
  \end{paracol}

  \begin{paracol}{2} % WRONG!
      \Blindtext[1]
    \switchcolumn
      \Blindtext[1]
  \end{paracol}

  \begin{paracol}{3} % this is what I want
      \blindtext
    \switchcolumn[1]
      \blindtext
    \switchcolumn[2]
      \blindtext
  \end{paracol}

\end{document}

答案1

可以通过\columnratio{0.5}组内设置暂时切换到双列模式。

\documentclass[parskip=full]{scrartcl}

\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{paracol}

\begin{document}

  \begin{paracol}{2} % this is what I want
      \Blindtext[1]
    \switchcolumn
      \Blindtext[1]
  \end{paracol}

\setcolumnwidth{2cm,3cm,4cm} % this should only affect the 3 column


\begin{paracol}{3} % this is what I want
  \blindtext
  \switchcolumn[1]
  \blindtext
  \switchcolumn[2]
  \blindtext
\end{paracol}

\begingroup
\columnratio{0.5}
\begin{paracol}{2} % WRONG!
  \color{red}
  \Blindtext[1]
  \switchcolumn
  \Blindtext[1]
\end{paracol}
\endgroup

\begin{paracol}{3} % this is what I want
  \blindtext
  \switchcolumn[1]
  \blindtext
  \switchcolumn[2]
  \blindtext
\end{paracol}

\end{document}

在此处输入图片描述

更新

\documentclass[parskip=full]{scrartcl}

\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{paracol}

\makeatletter
\newcommand{\setlocalcolumnwidth}[1]{%
  \let\oldratio\pcol@columnratioleft
  \setcolumnwidth{#1}%
}
\newcommand{\restorelocalcolumnwidth}{%
  \let\pcol@columnratioleft\oldratio%
}
\makeatother

\begin{document}

\columnratio{0.5}% Explicitly store the 0.5 ratio
\begin{paracol}{2} % this is what I want
  \Blindtext[1]
  \switchcolumn
  \Blindtext[1]
\end{paracol}


\setlocalcolumnwidth{2cm,3cm,4cm} % this should only affect the 3 column
\begin{paracol}{3} % this is what I want
  \blindtext
  \switchcolumn[1]
  \blindtext
  \switchcolumn[2]
  \blindtext
\end{paracol}
\restorelocalcolumnwidth


\begin{paracol}{2} % Works
  \color{red}
  \Blindtext[1]
  \switchcolumn
  \Blindtext[1]
\end{paracol}

\begin{paracol}{3} % this is what I want
  \blindtext
  \switchcolumn[1]
  \blindtext
  \switchcolumn[2]
  \blindtext
\end{paracol}

\begin{paracol}{2} % Works
  \color{red}
  \Blindtext[1]
  \switchcolumn
  \Blindtext[1]
\end{paracol}


\end{document}

相关内容