如何更新我现有的 MWE 文件中垂直和水平线上的四条相等的小相邻线,附上屏幕截图供您参考:
\documentclass{book}
\RequirePackage[breakable,hooks]{tcolorbox}
\tcbuselibrary{breakable,skins}
\makeatletter
\tikzstyle{dashedboxone}=[dash pattern=on 1.5pt off 1.2pt]
\newtcolorbox{Boxone}[1][]{%
enhanced,
breakable,
sharp corners,arc=0pt,outer arc=0pt,
boxrule=2pt,boxsep=0pt,top=9pt,left=9pt,right=9pt,bottom=6.5pt,middle=0pt,
colback=gray,
colframe=gray,
boxed title style={arc=0pt,outer arc=0pt,boxrule=0.5pt,boxsep=0pt,top=0pt,left=0pt,right=6pt,bottom=0pt,colframe=red,colback=gray},
title={\textcolor{green}{#1}},
toptitle=7.5pt,bottomtitle=3.5pt,
fonttitle=\sffamily,
pad at break=12pt,bottomrule at break=0pt,toprule at break=0pt,
borderline east={0.5pt}{-0.25pt}{blue,dashedboxone},
borderline west={0.5pt}{-0.25pt}{blue,dashedboxone},
borderline south={0.5pt}{-0.25pt}{blue,dashedboxone},
borderline north={0.5pt}{-0.25pt}{blue,dashedboxone},
%borderline={0.3pt}{-0.25pt}{boxonerulecolor,dashed},
}%
\makeatother
\begin{document}
\begin{Boxone}[VOICES FROM THE SECTOR]
\textit{“For our business, seasonality in terms of harvest cycles and consumer demand is a major factor.
Our customers have to pay for our services early in the season, but mostly generate profit only at
the end of the season.” – CEO of a company offering digital technologies for integration along
the value chain}
\textit{“Farmers are quite conservative. In our experience, they do not invest much per year and are quite
risk-averse. Hence, it is key to convince the farmer of the added value. Furthermore, data handling
is crucial.” – CEO of an innovative agri-tech company}
\end{Boxone}
\end{document}
答案1
如果你想在角落画一些特定的东西,你可以使用键frame code
而不是边框线,另请参阅包装手册overlay
第 9.2 节第 140 页。这是Ignasi 的回答。
这个想法是绘制角段并在这些角段之间绘制虚线。作为替代方案,xshift
可以使用yshift
tikzlibrarycalc
来计算角周围的位置。与另一个答案一样,如果虚线图案不适合框架的大小,这可能会导致虚线段不完整或在末端留下间隙。
梅威瑟:
\documentclass{book}
\RequirePackage[breakable,hooks]{tcolorbox}
\tcbuselibrary{breakable,skins}
\usetikzlibrary{calc}
\tikzstyle{dashedboxone}=[dash pattern=on 1.5pt off 1.2pt]
\newtcolorbox{Boxone}[1][]{%
enhanced,
breakable,
sharp corners,arc=0pt,outer arc=0pt,
boxrule=2pt,boxsep=0pt,top=9pt,left=9pt,right=9pt,bottom=6.5pt,middle=0pt,
colback=lightgray,
boxed title style={arc=0pt,outer arc=0pt,boxrule=0.5pt,boxsep=0pt,top=0pt,left=0pt,right=6pt,bottom=0pt},
title={\textcolor{green}{#1}},
toptitle=7.5pt,bottomtitle=3.5pt,
fonttitle=\sffamily,
pad at break=12pt,bottomrule at break=0pt,toprule at break=0pt,
frame code={
% fill the frame
\path[draw=none,fill=gray]
(frame.south west) rectangle (frame.north east);
% top left corner
\path[blue,draw] ($(frame.north west)-(0.2pt,0.7pt)$) -- ($(frame.north west)-(0.2pt,-0.2pt)$) -- ($(frame.north west)+(0.7pt,0.2pt)$);
% dash pattern from top left to top right
\path[blue,draw,dash pattern=on 1.5pt off 1.2pt] ($(frame.north west)+(1.9pt,0.2pt)$) -- ($(frame.north east)-(1.9pt,-0.2pt)$);
% top right corner
\path[blue,draw] ($(frame.north east)-(0.7pt,-0.2pt)$) -- ($(frame.north east)+(0.2pt,0.2pt)$) -- ($(frame.north east)+(0.2pt,-0.7pt)$);
% dash pattern from top right to bottom right
\path[blue,draw,dash pattern=on 1.5pt off 1.2pt] ($(frame.north east)+(0.2pt,-1.9pt)$) -- ($(frame.south east)+(0.2pt,1.9pt)$);
% etc.
\path[blue,draw] ($(frame.south east)+(0.2pt,0.7pt)$) -- ($(frame.south east)+(0.2pt,-0.2pt)$) -- ($(frame.south east)-(0.7pt,0.2pt)$);
\path[blue,draw,dash pattern=on 1.5pt off 1.2pt] ($(frame.south east)-(1.9pt,0.2pt)$) -- ($(frame.south west)+(1.9pt,-0.2pt)$);
\path[blue,draw] ($(frame.south west)+(0.7pt,-0.2pt)$) -- ($(frame.south west)-(0.2pt,0.2pt)$) -- ($(frame.south west)-(0.2pt,-0.7pt)$);
\path[blue,draw,dash pattern=on 1.5pt off 1.2pt] ($(frame.south west)-(0.2pt,-1.9pt)$) -- ($(frame.north west)-(0.2pt,1.9pt)$);
}
}%
\begin{document}
\begin{Boxone}[VOICES FROM THE SECTOR]
\textit{“For our business, seasonality in terms of harvest cycles and consumer demand is a major factor.
Our customers have to pay for our services early in the season, but mostly generate profit only at
the end of the season.” – CEO of a company offering digital technologies for integration along
the value chain}
\textit{“Farmers are quite conservative. In our experience, they do not invest much per year and are quite
risk-averse. Hence, it is key to convince the farmer of the added value. Furthermore, data handling
is crucial.” – CEO}
\end{Boxone}
\end{document}
结果:
答案2
如果要确保四个角都画得像一个角,可以明确地从角开始画虚线。但在这种情况下,这些线的中心部分将不正确。此解决方案如下所示boxone
。
如果您只想画四个角而不画其他内容,请查看boxtwo
。
\documentclass{book}
\RequirePackage[breakable,hooks]{tcolorbox}
\tcbuselibrary{breakable,skins}
\makeatletter
\tikzstyle{dashedboxone}=[dash pattern=on 1.5pt off 1.2pt]
\newtcolorbox{Boxone}[1][]{%
enhanced,
breakable,
sharp corners,
boxrule=2pt,boxsep=0pt,top=9pt,left=9pt,right=9pt,bottom=6.5pt,middle=0pt,
colback=gray!10,
%frame empty,
colframe=gray,
boxed title style={sharp corners, boxrule=0.5pt, boxsep=0pt, top=0pt, left=0pt, right=6pt, bottom=0pt, colframe=red, colback=gray},
title={\textcolor{green}{#1}},
toptitle=7.5pt,bottomtitle=3.5pt,
fonttitle=\sffamily,
pad at break=12pt,bottomrule at break=0pt,toprule at break=0pt,
%borderline east={0.5pt}{-0.25pt}{blue,dashedboxone},
%borderline west={0.5pt}{-0.25pt}{blue,dashedboxone},
%borderline south={0.5pt}{-0.25pt}{blue,dashedboxone},
%borderline north={0.5pt}{-0.25pt}{blue,dashedboxone},
%borderline={0.5pt}{-0.25pt}{blue,dashed},
overlay={
\draw[red, dashed] (frame.north west)--(frame.north);
\draw[red, dashed] (frame.north west)--(frame.west);
\draw[red, dashed] (frame.north east)--(frame.north);
\draw[red, dashed] (frame.north east)--(frame.east);
\draw[red, dashed] (frame.south west)--(frame.west);
\draw[red, dashed] (frame.south west)--(frame.south);
\draw[red, dashed] (frame.south east)--(frame.east);
\draw[red, dashed] (frame.south east)--(frame.south);
}
}%
\newtcolorbox{Boxtwo}[1][]{%
enhanced,
breakable,
sharp corners,
boxrule=2pt,boxsep=0pt,top=9pt,left=9pt,right=9pt,bottom=6.5pt,middle=0pt,
colback=gray!10,
%frame empty,
colframe=gray,
boxed title style={sharp corners, boxrule=0.5pt, boxsep=0pt, top=0pt, left=0pt, right=6pt, bottom=0pt, colframe=red, colback=gray},
title={\textcolor{green}{#1}},
toptitle=7.5pt,bottomtitle=3.5pt,
fonttitle=\sffamily,
pad at break=12pt,bottomrule at break=0pt,toprule at break=0pt,
%borderline east={0.5pt}{-0.25pt}{blue,dashedboxone},
%borderline west={0.5pt}{-0.25pt}{blue,dashedboxone},
%borderline south={0.5pt}{-0.25pt}{blue,dashedboxone},
%borderline north={0.5pt}{-0.25pt}{blue,dashedboxone},
%borderline={0.5pt}{-0.25pt}{blue,dashed},
overlay={
\draw[red] ([yshift=-1cm]frame.north west)|-([xshift=1cm]frame.north west);
\draw[red] ([yshift=-1cm]frame.north east)|-([xshift=-1cm]frame.north east);
\draw[red] ([yshift=1cm]frame.south west)|-([xshift=1cm]frame.south west);
\draw[red] ([yshift=1cm]frame.south east)|-([xshift=-1cm]frame.south east);
}
}
\makeatother
\begin{document}
\begin{Boxone}[VOICES FROM THE SECTOR]
\textit{“For our business, seasonality in terms of harvest cycles and consumer demand is a major factor.
Our customers have to pay for our services early in the season, but mostly generate profit only at
the end of the season.” – CEO of a company offering digital technologies for integration along
the value chain}
\textit{“Farmers are quite conservative. In our experience, they do not invest much per year and are quite
risk-averse. Hence, it is key to convince the farmer of the added value. Furthermore, data handling
is crucial.” – CEO of an innovative agri-tech company}
\end{Boxone}
\begin{Boxtwo}
\textit{“For our business, seasonality in terms of harvest cycles and consumer demand is a major factor.
Our customers have to pay for our services early in the season, but mostly generate profit only at
the end of the season.” – CEO of a company offering digital technologies for integration along
the value chain}
\end{Boxtwo}
\end{document}