0

My goal is to have inline code embedded in text using \DeclareTotalTCBox. The problem is that the box is not breakable (even though I used the breakable option). I looked at the manual (v 4.20) page 449, but I wasn't able to fix the problem. Any suggestions are welcomed! Thank you.

Output

\documentclass{article}
\usepackage{showframe}
\usepackage[most, breakable]{tcolorbox}
\DeclareTotalTCBox{\inline}{v}{ 
    nobeforeafter,
    breakable,
    tcbox raise = -4pt,
    top         = 0pt,
    bottom      = 0pt,
    left        = 0pt,
    right       = 0pt,
    colback     = lightgray,
    colframe    = black,
}{\lstinline[basicstyle = \scriptsize\color{red}\tt]^#1^}

\begin{document}
Here is some random text filling the line for my problem to appear \inline{inline code inserted}
and now, the line ended.
\end{document}
M. Al Jumaily
  • 4,035
  • 2
  • 11
  • 26
  • 1
    The breakable option in tcolorbox is intended to break boxes across pages, not from one line to the next. Related: https://tex.stackexchange.com/questions/459770/tcolorbox-breakable-inlined-box (actually it's a duplicate, I didn't mark it as duplicate because that question does not have a solution for the problem other than "it can't be done"). – Marijn Jun 03 '19 at 20:15
  • Thanks for the info. I have already seen the question you linked but it doesn't solve my problem as you suggested. – M. Al Jumaily Jun 03 '19 at 20:18
  • Package soul provides a command to highlight text which respect end of line breaks, but it won't draw border lines to highlighted text. As an alternative, you could try to adapt solutions in Cool Text Highlighting in LaTeX – Ignasi Jun 04 '19 at 07:42

0 Answers0