I defined a new command for highlighting some text parts:
\newcommand{\keyword}[1]{\colorbox{black!5}{#1}}
Unfortunately, when the text becomes to long it overlaps my margins.
The keyword ignores the margin of the table, as well as the margin of the hole document.
\keyword{exp: c=wordExp \{ if(\$c.matches(``a string'')\{
\textbackslash\textbackslash do something \}) \}}
Can I tell my command to make a newline or force it to break after X centimeters?
Thx.
Best Answer
You can use @barbarabeeton's advice. I don't recommend the name
\keyword
, however, because it is defined elsewhere in some classes. So, thenewcommand
can look like this:Observe this
-2\fboxsep
, which serves to align thecolorbox
with the text above and below. Here is a full example: