阴影多色 II

阴影多色 II

在延伸之前的问题时,阴影多色,如何在 multicol 环境中为外面的 4 个角(即紧挨着页边距的角)添加圆角

只有在使用多列阴影或多列边框时,这个问题才真正相关,解决方案包含在该问题的第一部分(参见上面的链接)。

因此,最重要的是环境需要能够在中途分页。David Carlisle 在一条评论中建议修补 box 命令,但如何才能做到这一点,只对左列的左侧 2 个角进行圆角处理,对右列的右侧 2 个角进行圆角处理,而中间列则不进行圆角处理(当有 3 列或更多列时)。

答案1

在此处输入图片描述

正如问题中提到的,这本质上只是替换了\fcolorboxmdframed感谢 Marco 提供了正确的mdframed咒语)

\documentclass{article}
\usepackage{multicol}
\usepackage[framemethod=tikz]{mdframed}

\makeatletter
\let\old@page@sofar\page@sofar
\let\old@box\box
\let\old@rlap\rlap
\def\page@sofar{%
\let\box\colorcolumn
\def\rlap{\let\box\old@box\old@rlap}%
\old@page@sofar
}
\def\colorcolumn#1{%
\ifnum#1=\mult@rightbox
\def\zz{\begin{mdframed}[middlelinewidth=2pt,roundcorner=5pt,leftline=false,backgroundcolor=yellow]}%
\fi
\ifnum#1=\numexpr\mult@rightbox+2\relax
 \def\zz{\begin{mdframed}[middlelinewidth=2pt,roundcorner=5pt,rightline=false,backgroundcolor=yellow]}%
\fi
\ifnum#1=\numexpr\mult@rightbox+4\relax
  \def\zz{\begin{mdframed}[middlelinewidth=2pt,roundcorner=5pt,rightline=false,leftline=false,backgroundcolor=yellow]}%
\fi
       \kern\dimexpr-15pt\relax
        {\let\box\old@box\vtop{%
          \zz{%
           \hbox{\box#1\llap{\phantom p}}}%
           \end{mdframed}}}%
        \kern\dimexpr-15pt\relax
}

\makeatother


\def\a{Red blue green yellow black white. }
\def\b{One two three four five six. }
\def\c{\stepcounter{enumi} \Roman{enumi}
\a\a\b\b\a\a\b\a\a\b\b\b\b\b\b\a\a\b}
\begin{document}

\begin{multicols}{3}
\c\c\c\c\c\c\c\c\c\c
\end{multicols}

\end{document}

相关内容