0

My aim is to make some sort of solutions to exercises. I have got some idea on using tcolorbox stuff, but this alignment issue seems pretty weird.

Here is what I have right now. enter image description here

What I want is, since 1.13 is some sort of problem index, It should go on top. I tried using sidebyside align=top but it doesn't work. How can I fix this issue?

The following is LaTeX code to reproduce above image.

\documentclass[a4paper, 10pt]{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\usepackage{tikz}
\usepackage{tikzpagenodes}

\parindent=0pt

\usepackage{xparse}
\begin{document}
    \begin{tcolorbox}[sidebyside,sidebyside align=top,lefthand width=1.5cm]
        \begin{tcolorbox}[width=\textwidth,before skip=0pt,boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
            {\sffamily \bfseries {\color{purple}\S 1.13}}
        \end{tcolorbox}
    \tcblower
        \begin{tcolorbox}[width=\textwidth,before skip=0pt,boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
            \lipsum[1]
        \end{tcolorbox}
    \end{tcolorbox}
\end{document}

Any ideas to fix the issues?

Thanks for reading.

2
  • Welcome to TeX.SE!
    – Mensch
    Aug 29, 2021 at 19:50
  • sidebyside align=topworks, but the suboxes are like two single characters aligned in the first (and unique) line at the baseline. Is the same problem that align a with A. If you change \lipsum[1]\end{tcolorbox} by \lipsum[1][1] \end{tcolorbox} \lipsum[2-3] you will see what I mean.
    – Fran
    Aug 29, 2021 at 23:05

1 Answer 1

0

side by side alignment options include top seam which do what you want as it's shown in following first example.

Your example shows nested tcolorboxes. This means that the boxes are not breakable. If this is your intention, I've nothing to say. But, in any case, I propose a similar format, without the external box, which allows breakable boxes and an automatic counter for the boxes.

\documentclass[a4paper, 10pt]{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\usepackage{tikz}
\usepackage{tikzpagenodes}

\parindent=0pt

\newtcolorbox[auto counter, number within=section]{problem}[1][]{enhanced, attach boxed title to top left={yshift=-\tcboxedtitleheight, xshift=-2cm}, left skip=2cm,
    colbacktitle=tcbcolback, coltitle=purple, fonttitle=\sffamily\bfseries,
    boxed title size=title,
    boxed title style={text width=1.8cm},
    title={\S \thetcbcounter},#1
}


\usepackage{xparse}
\begin{document}
    \begin{tcolorbox}[sidebyside,sidebyside align=top seam,lefthand width=1.5cm]
        \begin{tcolorbox}[width=\textwidth,before skip=0pt,boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
            {\sffamily \bfseries {\color{purple}\S 1.13}}
        \end{tcolorbox}
    \tcblower
        \begin{tcolorbox}[width=\textwidth,before skip=0pt,boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
            \lipsum[1]
        \end{tcolorbox}
    \end{tcolorbox}
    
    \begin{problem}
    \lipsum[1]
    \end{problem}
\end{document}

enter image description here

1
  • Thanks for the answer and additional advice. I am completely new to this package (tcolorbox) and wasn't aware of such features. Your solution seems to work great!
    – 72G
    Aug 30, 2021 at 17:53

You must log in to answer this question.

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