4

This is pretty much a '17 version of this question, since the solution provided does not work (anymore) in this case and neither does any of these other answers, because tabu has its own rules.

The syntax highlighting works, using mintinline in the cell correctly highlights the code. There are no visible problems, it just throws the following error: Package minted Error: Missing Pygments output; \inputminted wasor may be using frozencache with a missing file. \end{tabu}

Here is a short MWE and the compilation result:

\documentclass[preview]{standalone}
\usepackage{tabu,minted}
\begin{document}
    \mintinline{html}{<p>This works</p>}
    \begin{table}[htb]
        \centering
        \begin{tabu} to \linewidth {l | X[c] | c}
            Col1 & Col2                                   & Col3 \\
            \hline
            A    & \mintinline{html}{<p>This doesn't</p>} & B    \\
            C    & D                                      & E    \\
        \end{tabu}
        \caption{MWE Table}
        \label{tbl:table}
    \end{table}
\end{document}

result of MWE compilation

Applying the fix from the first linked answer does not work and does not alter the given error message. Other than that, I did not find anything helpful in neither the tabu nor the minted documentation.

6

This seems to work: using \tabuDisableCommands to let \mintinline do something different and less complicated during the measuring phase and only do its thing during typesetting.

It has a drawback, though: \detokenizeing is not the same as verbatim input so this solution will fail in certain cases. In tables like the one of the OP where the column width doesn't depend on the actual content of \mintinline a safer \renewcommand\mintinline[2]{} would also do.

\documentclass{article}
\usepackage{tabu,minted}

\tabuDisableCommands{%
  \renewcommand\mintinline[2]{\texttt{\detokenize{#2}}}%
}

\begin{document}

\mintinline{html}{<p>This works</p>}
\begin{table}[htb]
  \centering
  \begin{tabu} to \linewidth {l | X[c] | c}
    Col1 & Col2                                   & Col3 \\
    \hline
    A    & \mintinline{html}{<p>This doesn't</p>} & B    \\
    C    & D                                      & E    \\
  \end{tabu}
  \caption{MWE Table}
  \label{tbl:table}
\end{table}

\end{document}
  • Thank you for this solution, this appears to be working fine, both in the MWE and in my working document. According to the current tabu documentation, the command \tabuDisableCommands does "change the definition of some commands during the trial loops", which you are using to replace the meaning of \mintinline to a detokenized typewriter-text version. Am I correct in assuming that the trial runs are used to determine the column width and thus tabu is now using a less complicated macro for these runs to avoid the error, only applying syntax highlighting in the final run? – Big-Blue May 28 '17 at 13:00
  • @Big-Blue yes, exactly – clemens May 28 '17 at 13:05
  • Thanks, I've marked this answer as accepted. Should future, similar problems with tabu arise in the future, I now know of a possible way to handle them. – Big-Blue May 28 '17 at 13:15

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.