0

mdframed always creates bad breaks, I tried to solve this and read about people saying it is not supported anymore and that tcolorbox is a better solution. I recreated my theorem boxes with tcolorbox but now I'm facing a text alignment issue: when the title gets too long, the alignment changes. I did a comparison between mdframed with a short title, mdframed with a long title, tcolorbox with a short title and tcolorbox with a long title.

see the gap

Here is my code :

\begin{boiterouge}[\textbf{\textsc{The-rem} -- title some title mdframed}]
This is some random text
\end{boiterouge}

\begin{boiterouge}[\textbf{\textsc{The-rem}}]
This is some random text
\end{boiterouge}

\begin{tcolorbox}[enhanced,title=\textbf{\textsc{The-rem} -- title some title tcolorbox} ,colframe=rougestyle,coltitle=rougestyle,colback=white,
attach boxed title to top left=
{yshift=-3mm,xshift=4mm},left=2.5mm,top=2mm,bottom=0.5mm,
boxed title style={opacityback=0,colframe=white,size=fbox,arc=0mm},sharp corners]
This is some random text
\end{tcolorbox}

\begin{tcolorbox}[enhanced,title=\textbf{\textsc{The-rem}} ,colframe=rougestyle,coltitle=rougestyle,colback=white,
attach boxed title to top left=
{yshift=-2.5mm,xshift=4mm},
boxed title style={opacityback=0,colframe=white,size=fbox,arc=0mm},sharp corners]
This is some random text
\end{tcolorbox}
3
  • 1
    Welcome to TexExchange. If I understood correctly the question p.166 of the doc {yshift=-\tcboxedtitleheight/2,xshift=4mm}, Please the next time post a minimal code directly compilable MWE.
    – pascal974
    Commented May 15, 2022 at 12:26
  • Your solution seems to work, thank you. Sorry for the MWE, I will not forget next time.
    – Flowt
    Commented May 15, 2022 at 12:40
  • It's no good, see the answer
    – pascal974
    Commented May 16, 2022 at 5:39

1 Answer 1

2

My comment is no good! If there is a letter with a depth (g, j, p, q) in the title, the alignment changes

enter image description here

With \vphantom{p}, a letter with a depth, the alignment will be the same. Surely there is better to do.

    \documentclass{article}
    \usepackage{tcolorbox}
    \tcbuselibrary{skins}
    \begin{document}
    \tcbset{%
    enhanced,
    colframe=red,
    coltitle=red,
    colback=yellow,
    boxed title style={opacityback=0,colframe=white,size=fbox,arc=0mm},
    attach boxed title to top left={yshift=-\tcboxedtitleheight/2,xshift=4mm}
    }%

    \begin{tcolorbox}[title=\textbf{\textsc{The-rem}}]
    Without vphantom{bp}
    \end{tcolorbox}
    \begin{tcolorbox}[title=\textbf{\textsc{The-remg}}]
    Without vphantom{bp}
        \end{tcolorbox}
    \begin{tcolorbox}[title=\textbf{\textsc{The-rem} -- title some title tcolorbox}]
        Without vphantom{bp}
    \end{tcolorbox}
    \begin{tcolorbox}[title=\textbf{\vphantom{bp}\textsc{The-rem} -- title some title tcolorbox}]
        With vphantom{bp}
    \end{tcolorbox}
    \end{document}

You must log in to answer this question.

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