When using a tabular
with textwidth (manually calculated) it turns out to be wider than the minipage created by \tcblisting
:
\documentclass{article}
\newlength\mylenA
\newlength\invoicedescwidth
\usepackage{tcolorbox}
\tcbuselibrary{listings}
\usepackage{tabularx}
\begin{document}
\begin{tcblisting}{title=tabular with manual column widths}
\settowidth\mylenA{%
\textsf{\textbf{Pos.Total sum}}}
\setlength\invoicedescwidth{%
\dimexpr\textwidth-\mylenA\relax}
\begin{tabular}
{
r
p{\invoicedescwidth}
r
}%
\textbf{Pos.} & \textbf{Other text} & \textbf{Total sum} \\
\hline\\
\end{tabular}
\end{tcblisting}
\begin{tcblisting}{title=tabularx with textwidth}
\begin{tabularx}{\textwidth}
{
r
X
r
}%
\textbf{Pos.} & \textbf{Other text} & \textbf{Total sum} \\
\hline\\
\end{tabularx}
\end{tcblisting}
\end{document}
Tabularx work. Should both not be the same? I do not want to use tabularx since the multiple calls during the LaTeX build break calculations that are done in tabularx...