3

I'd like to debug some width problems in the following code, but the \typeout prints commands instead of actual value:

\documentclass{article}
\usepackage[margin=3cm]{geometry}
\usepackage{array}
\usepackage{booktabs}
\usepackage[table]{xcolor}
\usepackage{tabularx}

\begin{document}

\newenvironment{messageWithProperties}[1]
    {
      \noindent
      \tabularx{\textwidth}{>{\bfseries}lX}
          \toprule
          \midrule
          header &
              $\left\{\tabular{>{\bfseries}l l >{\sffamily}p{\dimexpr\textwidth-12\tabcolsep-5\fboxsep-7.5cm\relax}}
                  \toprule
                  id & integer & desc \\
                  key & integer & desc \\
                  \bottomrule
              \endtabular\right\}$ \\[4ex]
          \midrule
          #1 &
              $\left\{\tabular{>{\bfseries}l l >{\sffamily}p{\dimexpr\textwidth-12\tabcolsep-5\fboxsep-7.5cm\relax}}
                  \toprule
                  \typeout{Debug \dimexpr\textwidth-3\tabcolsep-5\fboxsep-7.5cm\relax}
    }
    {
                  \bottomrule
              \endtabular\right\}$ \\[4ex]
          \midrule
          \bottomrule
      \endtabularx
    }

\begin{messageWithProperties}{someVeryLongName}
    userId & string & desc \\
    propertyName & veryLongStringType & a very very long description of the field \\
\end{messageWithProperties}

\end{document}

(code is from the "How to limit the width of a nested table?" question)

5

a \dimexpr is like an anonymous dimen register and the same commands apply so \the will give its print form

\the\dimexpr\textwidth-3\tabcolsep-5\fboxsep-7.5cm\relax

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.