带方形/圆形边缘的集中式/侧式盒子

带方形/圆形边缘的集中式/侧式盒子

我正在尝试精确地重现下面的框,即带有圆边的中央框和带有方边的侧面框。

我找到了一些关于彩色盒子的文章,这些盒子背面有阴影,里面有图片等等。但我只想要这种简单的格式,和图片中的完全一样。

最好的解决办法是什么?

答案1

tcolorbox手动的对于参数的解释。

\documentclass{book}
%\usepackage{showframe}% only for testing purpose
\usepackage[most]{tcolorbox}
\tcbset{
    opacityback=0,
    enhanced jigsaw,
    opacitybacktitle=0,
    coltitle=black,
    fonttitle=\bfseries,
    titlerule=0pt,
    titlerule style=white,
    toptitle=4pt,
    bottomtitle=0pt,
    top=2pt,
    left=1mm,
    right=1mm,
    }
\newtcolorbox{mydef}{
    title=Definition,
    grow to left by=2.5mm,% sum of the values: 1mm left margin + 1mm box sep + 0.5mm box rule = 2.5mm
    grow to right by=2.5mm,
    arc=3mm
    }
\newtcolorbox{mymarpar}[1]{
    title={\centering #1},
    sharp corners,
    grow to left by=-2.5mm
    }

\usepackage{mwe}% only for testing purpose

\begin{document}
\chapter{A chapter}
\section{A section}
\blindtext% only for testing purpose
\begin{mydef}
This is my definition. Blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah.
\end{mydef}
Some text blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah

\marginpar{\begin{mymarpar}{The title of my first margin par}
Some text in my first marigin par blah blah blah    
\end{mymarpar}}

Some other text blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah

\marginpar{\begin{mymarpar}{The title of my second margin par}
Some text in my second marigin par blah blah blah 
\end{mymarpar}}

\blindtext % only for testing purpose
\end{document}

在此处输入图片描述

正如 Skillmon 在他的评论中所建议的那样,如果您使用,\marginnote您可以更好地控制边距中框的垂直位置。

\documentclass{book}
\usepackage{marginnote}
%\usepackage{showframe}% only for testing purpose
\usepackage[most]{tcolorbox}
\tcbset{
    opacityback=0,
    enhanced jigsaw,
    opacitybacktitle=0,
    coltitle=black,
    fonttitle=\bfseries,
    titlerule=0pt,
    titlerule style=white,
    toptitle=4pt,
    bottomtitle=0pt,
    top=2pt,
    left=1mm,
    right=1mm,
    }
\newtcolorbox{mydef}{
    title=Definition,
    grow to left by=2.5mm,% sum of the values: 1mm left margin + 1mm box sep + 0.5mm box rule = 2.5mm
    grow to right by=2.5mm,
    arc=3mm
    }
\newtcolorbox{mymarpar}[1]{
    title={\centering #1},
    sharp corners,
    grow to left by=-2.5mm
    }

\usepackage{mwe}% only for testing purpose

\begin{document}
\chapter{A chapter}
\section{A section}
\blindtext% only for testing purpose
\begin{mydef}
This is my definition. Blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah.
\end{mydef}
Some text blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah

\marginnote{\begin{mymarpar}{The title of my first margin par}
Some text in my first marigin par blah blah blah    
\end{mymarpar}}[-102pt]

Some other text blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah

\marginnote{\begin{mymarpar}{The title of my second margin par}
Some text in my second marigin par blah blah blah 
\end{mymarpar}}[14pt]

\blindtext % only for testing purpose
\end{document}

在此处输入图片描述

相关内容