3

How to avoid new line jump after each tcolorbox ?

\documentclass[10pt,a5paper,landscape]{article}
\usepackage{pgffor,luacode,array,tcolorbox,bm,geometry}

\geometry{margin=1.5cm}
\pagestyle{empty}

\begin{luacode}
function Table (n)
    for i=1,10
    do
        tex.print(i.."&\\bm{"..n.."}&"..i*n.."\\\\")
    end
end
\end{luacode}

\newcommand{\Table}[1]{%
    \begin{tcolorbox}[width=.18\linewidth,colback={white},
        title={\textbf{\vphantom{Éq}%
        \Large\hfill\textsf{Table de #1}\hfill\strut}},%
        colbacktitle=gray!75,coltitle=white,
        left=1mm,top=1mm,right=1mm,bottom=1mm]
    \large
    \hfill$\begin{array}{r@{\;$\times$\;}c@{\;=\;}r}
        \directlua{Table(#1)}
    \end{array}$\hfill\strut
    \end{tcolorbox} bob}

\begin{document}

\foreach \i in {1,...,5} {\Table{\i}}

\end{document}
  • Try with the option nobeforeafter --- worked for me. Maybe with the hbox option too. – Rmano Oct 1 '18 at 8:33
  • 1
    Ok for me. Thank you. Consider to write an answser. – Tarass Oct 1 '18 at 8:53
4

Normally tcolorbox try to typeset the box as a paragraph; to do that sets the keys before and after to a value that is dependent on the presence or not of the package parskip (guessed, really). Typically they are something like:

before={\par\pagebreak[0]\smallskip\parindent=0pt}, after={\par\smallskip}

If you want to clear the default values, use the key nobeforeafter; in the manual (pag. 78 in my copy, version 4.12) it states:

Abbreviation for clearing the keys before and after. The colored box is not put into a paragraph and there is no space before or after the box.

Moreover, the option hbox is needed sometime; this will size the box according to the content (and no the other way around; pag. 94):

capture=hbox: This is the default mode for \tcbox. The content cannot have a lower part and cannot be broken. The colored box is sized according to the dimensions of the content. A shortcut to set this mode is /tcb/hbox.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.