0

I'd like to make up a style in tcolorbox to get an effect as like "s" option in \makebox. code example like this:

\documentclass{article}
\usepackage[most]{tcolorbox}

\begin{document}
\tcbset{style like makebox/.style={...}}
\begin{tcbitemize}
  \tcbitem[style like makebox] I am a doctor
  \tcbitem I am a doctor
\end{tcbitemize}

\end{document}

I want the above code to get the effect as shown in the attached figure like this:enter image description here

1 Answer 1

2

I don't know how robust this is, but the following works:

\documentclass{article}
\usepackage[most]{tcolorbox}

\begin{document}
\tcbset{style like makebox/.style={fontupper=\parfillskip0pt}}
\begin{tcbitemize}
  \tcbitem[style like makebox]  I am a doctor
  \tcbitem I am a doctor
\end{tcbitemize}

\end{document}

enter image description here

5
  • Many thanks @Skillmon! It does work! And a further question: if there is "\\'' in the content of \tcbitem, then the first line loses this ability., for example, "some text\\some text". The first "some text" will be flush left. Is there a better way to solve this? And, could you tell me how "fontupper=\parfillskip0pt" works in my example code?
    – lyl
    Oct 29, 2018 at 9:59
  • 1
    @lyl Use \linebreak instead of \\ .
    – Skillmon
    Oct 29, 2018 at 10:10
  • And how to give "style like makebox/.style" a higher priority. For example, "\tcbitem[halign=center, style like makebox] some text", the later style will be overrided by the former.
    – lyl
    Oct 29, 2018 at 10:35
  • 1
    @lyl include a halign=justify in the definition.
    – Skillmon
    Oct 29, 2018 at 11:53
  • @ Skillmon So simple but so effective solution! Thank you!!
    – lyl
    Oct 29, 2018 at 13:23

You must log in to answer this question.

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