tcolorbox 或 parcolumns 无法正确呈现我的食谱

tcolorbox 或 parcolumns 无法正确呈现我的食谱

我目前正在编写我的法国食谱书的新版本(我的意思是,它是法语的)。

我的问题是我想要的食谱看起来像:

我想要的是

这种风格由两个独立的列组成,每个列都包含一个类似 iemize 的结构。

我的需求:

  1. 两列应独立
  2. 它应该在页面末尾断开(即,它应该像伪列在另一页上一样断开)。

第一次尝试:tcolorbox

上面的例子使用了 sidebyside tcolorbor。它运行良好,tcolorbox 的光栅库也是如此,但它不会在页面末尾中断。

第二次尝试:parcolumns

对于像 lipsum 给出的段落,这似乎效果很好,但对于 itemize 样式的环境似乎存在一些问题。这是我在有分页符和没有分页符的情况下得到的结果。

在此处输入图片描述

在此处输入图片描述

问题是:1. 左侧项目空间太短 2. 右侧项目空间太大 3. 奇怪的附加空格(在第一个枚举上方)。

我在这个论坛上看到了一个解决方案,其中提出了一个小型页面来解决这些问题,但它将无法打破:s

结论

我似乎尝试了不同的解决方案,但都没有奏效。你有什么想法吗?

最小工作示例。

\documentclass{article}
\usepackage{showframe}

%% With tcolorbox

\usepackage[most]{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable, skins}

\tcbset{colback=white,colframe=white, left skip=0pt, right skip=0pt, left=0pt, right=0pt, top=0pt, bottom=0pt, rightrule=0pt, leftrule=0pt, toprule=0pt, bottomrule=0pt, sharp corners,  breakable}

\newcommand\itemlist{
    \subsection{Ingredients}
    \begin{itemize}
      \item Element 1
      \item Element 2
      \item Element 3
      \item Element that is quite long
      \item Some nice cheeze
    \end{itemize}
}

\newcommand\enumlist{
    \subsection{Preparation}
    \begin{itemize}
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
    \end{itemize}
}

\newcommand\recipe{
\section{tcolorbox Lipsum}

\begin{tcolorbox}[sidebyside,lefthand width=3cm, sidebyside align=top seam, breakable]
  \itemlist
\tcblower
  \enumlist
\end{tcolorbox}

}

%% With parcolumns
\usepackage{parcolumns}

\newcommand\recipebis{
    \section{parcolumns Lipsum}

    \begin{parcolumns}[colwidths={1=3cm}, distance=3em]{2}
        \colchunk[1]{\itemlist}
        \colchunk[2]{\enumlist}
        \colplacechunks
    \end{parcolumns}
}

\begin{document}

% A test
\section{Test}
\itemlist
\enumlist

% With tcolorbox
\newpage
\recipe
\recipe
\rule{5cm}{1cm}
\recipe

% With parcolumns
\newpage
\recipebis
\recipebis
\recipebis
\rule{1cm}{1cm}
\recipebis
\recipebis

\end{document}

答案1

您可以尝试使用paracol包。它以独立的方式打破列,并且似乎尊重itemize距离。如果您发现对齐窄列存在问题,您可以将其与 tcolorbox 结合使用,blanker如图所示这里

\documentclass{article}
\usepackage{showframe}
\usepackage{paracol}

\newcommand\itemlist{
    \subsection{Ingredients}
    \begin{itemize}
      \item Element 1
      \item Element 2
      \item Element 3
      \item Element 1
      \item Element 2
      \item Element 3
      \item Element 1
      \item Element 2
      \item Element 3
      \item Element 1
      \item Element 2
      \item Element 3
      \item Element 1
      \item Element 2
      \item Element 3
      \item Element 1
      \item Element 2
      \item Element 3
      \item Element 1
      \item Element 2
      \item Element 3
      \item Element that is quite long
      \item Some nice cheeze
    \end{itemize}
}

\newcommand\enumlist{
    \subsection{Preparation}
    \begin{itemize}
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
      \item Preparation 1
      \item Preparation 2
      \item Preparation 3
      \item Preparation that is quite long
      \item Some nice cheeze at the end.
    \end{itemize}
}

\newcommand\recipeparacol{
}

\begin{document}
    \setcolumnwidth{3cm, 7cm}
    \setlength{\columnsep}{3em}

    \section{paracol Lipsum}
    \begin{paracol}{2}
        \itemlist
        \switchcolumn
        \enumlist
    \end{paracol}

\end{document}

在此处输入图片描述

相关内容