0

Here is a command I have:

\newcommand{\numbox}[2]{$^{\circled{#1}}${\fbox{#2}}}

What it does is boxing and numbering a text. However I for the box to break nicely across lines. In command \fbox{text} the text may stick out of the margins if the line is full. However I want to write a conditional for this case. Such as:

until text finished
after every word: 
   if there is \linebreak:
       end \fbox
       continue text with \fbox

enter image description here enter image description here

In above I added Images!

%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%

I used multiline colored box but as I said, since sentences are small it doesn’t look that nice tbh. Here is the image:

enter image description here

2 Answers2

1

Not an answer, but just a suggestion: tcolorbox

enter image description here

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum} % for dummy text
\newtcbox[auto counter]{\solution}[1][]{%
fonttitle=\bfseries\sffamily,
tcbox raise=-4mm,
grow to left by=-90pt, 
attach boxed title to top left={xshift=-90pt,yshift=-20pt}, 
enhanced,
tcbox width=auto limited, 
title= Solution ~\thetcbcounter #1}
\begin{document}
\lipsum[2]
\solution{\lipsum[1][1]}
\solution{\lipsum[3][1]}
\solution{\lipsum[3][1-5]}
\lipsum[4]
\end{document}
Fran
  • 80,769
0

Also not an answer, but to my mind one of the most useful source: https://tools.ietf.org/doc/texlive-doc/latex/tcolorbox/tcolorbox.pdf

WinnieNotThePooh
  • 3,008
  • 1
  • 7
  • 14