# Four corners equal edges in tcolorbox

How to update four equal small adjacent line in both vertical and horizontal line in my existing MWE file, screenshot attached for your reference:

\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}

• I think this won't happen unless horizontal and vertical borders are proportional to your "dashed" definition. – Ignasi May 2 '19 at 8:19
• I'm not really sure how you want the output to look. Should the dashes be 'finished', i.e., full length (1.5pt)? This of course depends on the width and height of your box as @Ignasi has commented, if your box is a multiple of 2.7pt then the pattern 'fits' (or maybe n x 2.7 - 1.2 to start and end with a dash), otherwise it doesn't fit and the dash will go around the corner. So a solution for that is to either change the size of your box or to change the size of your pattern, which one do you want? – Marijn May 2 '19 at 11:24
• Or you explicitly want these 'hooks' as in your example image? You can draw them separately, but they might overlap with your pattern depending on the size of your box. – Marijn May 2 '19 at 11:25
• Suppose if we take four corner as image how to place images four corner in the Boxes? Just give an idea to place image in four corner of boxes. – Rajesh N May 2 '19 at 11:47

If you want to draw something specific in the corners you can use the frame code key instead of the border lines, see also the package manual section 9.2 on page 140. This is an alternative to the overlay approach in Ignasi's answer.

The idea is to draw corner segments and to draw the dashed lines in between those corner segments. As alternative to xshift and yshift the calc tikzlibrary can be used to calculate the positions around the corners. As in the other answer, this may cause the dashed line segments to be incomplete or to leave a gap at the end in case the dash pattern does not fit the size of the frame.

MWE:

\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}


Result:

• This is excellent answers for my questions, above code is helpful to our design. – Rajesh N May 2 '19 at 13:17

If you want to be sure that four corners are drawn like a corner, you can explicitly start your dashed lines on corners. But in this case, the central part of these lines won't be correct. This solution is shown in following boxone.

If you just want to draw four corners and nothing else, look at 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}