如何使用tcolorbox制作部分双框?

如何使用tcolorbox制作部分双框?

tcolorbox似乎是一个非常强大的软件包,所以我很确定它可以做我想要做的事情,但我找不到它。

这就是我想要制作的:

在此处输入图片描述

这就是我能得到的:

在此处输入图片描述

梅威瑟:

\documentclass{scrartcl}
\usepackage[most]{tcolorbox}
\newtcbox{\one}[1][]{%
  enhanced,
  after skip=10pt,
  sharp corners,
  borderline={1pt}{-3pt}{black},
  toprule=0pt,
  rightrule=0pt,
  bottomrule=.5pt,
  leftrule=.5pt,
  colback=white,
  #1
}
\newtcbox{\two}[1][]{%
  enhanced,
  after skip=10pt,
  sharp corners,
  borderline west={1pt}{3pt}{black},
  borderline south={1pt}{3pt}{black},
  toprule=0pt,
  rightrule=0pt,
  bottomrule=.5pt,
  leftrule=.5pt,
  colback=white,
  colframe=black,
  #1}
\newtcbox{\three}[1][]{%
  enhanced,
  after skip=10pt,
  sharp corners,
  borderline west={1pt}{-3pt}{black},
  borderline south={1pt}{-3pt}{black},
  toprule=0pt,
  rightrule=0pt,
  bottomrule=.5pt,
  leftrule=.5pt,
  colback=white,
  colframe=black,
  #1}

\begin{document}
\one{I don't what the top and right frame border.}

\two{I don't what the lines to cross at the bottom left corner.}

\three{I'd like to join the lines at the bottom left corner.}
\end{document}

我有一个使用的工作框架mdframed,但我不能使用它,因为我需要它在 内工作\settowidth,并且那一个没有

答案1

例如,你可以使用

\newtcbox{\three}[1][]{%
    enhanced,
    frame hidden,colback=white,enhanced,overlay unbroken={%
            \draw[thick,red,double] (interior.north west)--(interior.south west)--(interior.south east);
        },
    #1}

输出如下

在此处输入图片描述

% arara: pdflatex
\documentclass{article}

\usepackage[most]{tcolorbox}

\newtcbox{\three}[1][]{%
    enhanced,
    frame hidden,colback=white,enhanced,overlay unbroken={%
            \draw[thick,red,double] (interior.north west)--(interior.south west)--(interior.south east);
        },
    #1}

\begin{document}

\three{here is some text}

\end{document}

如果您希望它能够跨页,那么您可以定义,例如:

\newtcolorbox{four}[1][]{%
    enhanced,
    breakable,
    frame hidden,
    colback=white,
    overlay unbroken={%
            \draw[thick,red,double] (interior.north west)--(interior.south west)--(interior.south east);
        },
    overlay first={
            \draw[thick,red,double] (interior.north west)--(interior.south west);
        },
    overlay middle={
            \draw[thick,red,double] (interior.north west)--(interior.south west);
        },
    overlay last={
            \draw[thick,red,double] (interior.north west)--(interior.south west)--(interior.south east);
        },
    #1,
}

然后使用:

\begin{four}
    \lipsum
\end{four}

输出结果如下:

在此处输入图片描述

在此处输入图片描述

相关内容