4

When using sidebyside, the right part of the tcolorbox do not seem to honor the margins.

Consider:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
%\tcbuselibrary{skins}

\newtcolorbox{EmR}{%
  sidebyside,sidebyside align=top,lower separated=true,lefthand width=0.4em,
  arc=8pt,
  boxsep=0pt,
  left=8pt,right=2pt,top=2pt,bottom=2pt,
  fontupper=\Large\bfseries\rm,
  fontlower=\small,
  after=\smallskip,
  skin=bicolor,
  colback=black!60, colframe=black!60,
  colupper=white,
  colbacklower=white,boxrule=0.5pt,
}

\begin{document}

\begin{EmR}
R
\tcblower
\lipsum[1]
\end{EmR}

\end{document}

screenshot

(I would like to reduce the space in blue to reflect my margins.)

Bonus point: Do you guys have any suggestions as to how to have more margin between the "R" and the frame (without increase the margin for the part at the right?)

1 Answer 1

7

You can adjust lefthand width=1.5em, and use sidebyside gap=2pt, to get

enter image description here

I don't think I understand the bonus question properly. It means probably this:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
%\tcbuselibrary{skins}

\newtcolorbox{EmR}{%
  sidebyside,sidebyside align=top,lower separated=true,lefthand width=1.8em,
  arc=8pt,
  boxsep=0pt,
  left=8pt,right=2pt,top=2pt,bottom=2pt,
  fontupper=\Large\bfseries\rmfamily,
  fontlower=\small,
  after=\smallskip,
  skin=bicolor,
  colback=black!60, colframe=black!60,
  colupper=white,
  colbacklower=white,boxrule=0.5pt,
  sidebyside gap=2pt,
}

\begin{document}

\begin{EmR}
\raisebox{-1ex}{R}
\tcblower
\lipsum[1]
\end{EmR}

\end{document}

enter image description here

If the upper part has only one letter like R, then the following is also possible:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
%\tcbuselibrary{skins}

\newtcolorbox{EmR}[1][]{%
  arc=8pt,
  boxsep=0pt,
  left=3em,,right=2pt,top=2pt,bottom=2pt,
  fontupper=\small,
  after=\smallskip,
  skin=bicolor,
  colback=white,colframe=black!60,
  boxrule=0.5pt,
  overlay={\begin{tcbclipinterior}
             \draw[black!60,line width=6em-4pt] (interior.north west)--(interior.south west);
             \node[font=\Large\bfseries\rmfamily, text=white, anchor=north west, inner ysep=5pt, minimum width=3em]
                    at (frame.north west) {#1};
           \end{tcbclipinterior}
  }
}

\begin{document}

\begin{EmR}[R]
\lipsum[1]
\end{EmR}

\end{document}

enter image description here

Adjust left=3em,, line width=6em-4pt (6em=2 times the left margin and 4pt = 2 times the right margin), inner ysep=5pt, minimum width=3em (minimum width=left).

1
  • Very complete. Hopefully it will be hopeful to others as well. Thank you :) Sep 18, 2015 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .