# Centralized/lateral boxes with squared/round edges

I'm trying to reproduce the boxes below exactly, i.e., a central box with round edges and a lateral box with squared edges.

I've found articles teaching about coloured boxes, with shadows on the back, pictures inside etc. But I just want this simple format, exactly like the ones in the picture.

What's the best solution?

• Welcome to TeX.SX! The best solution to reproduce it exactly might be to ask the author what they used. If you want something very, very close you can use tcolorbox and tweak it (the manual shows the many options). Please help us help you by providing a minimal compilable code example (MWE) showing what you've tried so far. – TeXnician Nov 10 '18 at 12:45

See tcolorbox manual for the explanation of the parameters.

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


As Skillmon suggested in his comment, if you use \marginnote you can have better control over vertical placement of the boxes in the margin.

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


• For better control over vertical placement of the boxes in the margin one might be interested in using marginnote for the placement. – Skillmon Jan 6 at 18:43
• That wasn't meant as a suggested correction, just as an additional option for perfectionists. Your answer looks great as is. – Skillmon Jan 6 at 19:52