我有以下文件:
\documentclass[parskip=half-]{scrreprt}
\usepackage{ragged2e}
\usepackage{makecell,xltabular}
\usepackage[dvipsnames,x11names,table]{xcolor}
\begin{document}
\subsection{Test table}
\begin{xltabular}{\textwidth}{|>{\ttfamily\RaggedRight\arraybackslash}p{6.5cm}|>{\centering\arraybackslash}p{0.6cm}|m{1.8cm}|X|}
\caption{Table caption}
\label{tab:test-table}\\
\hline
\rowcolor{gray}
\thead{\textnormal{Col1}} & \thead{Col2} & \thead{Col3} & \thead{Col4} \\ \hline
\endfirsthead
%
\multicolumn{4}{c}%
{{\bfseries Table \thetable\ continued from previous page}} \\
\hline
\rowcolor{gray}
\thead{\textnormal{Col1}} & \thead{Col2} & \thead{Col3} & \thead{Col4} \\ \hline
\endhead
%\
\multicolumn{4}{|c|}{\cellcolor{lightgray}\textbf{Table section}} \\ \hline
1 & 2 & 3 & 4 \\ \hline
\input{|"./test.py"}
\end{xltabular}
\end{document}
我正在使用\input
带有管道:
\input{|"./test.py"}
假如的内容test.py
是:
#!/usr/bin/env python3
print(r'\multicolumn{4}{|c|}{\cellcolor{lightgray}\textbf{Table section 2}} \\ \hline')
print(r'11 & 22 & 33 & 44 \\ \hline')
我收到一个错误:
! Misplaced \omit.
\multispan ->\omit
\@multispan
l.1 ...llcolor{lightgray}\textbf{Table section 2}}
\\ \hline
! ==> Fatal error occurred, no output PDF file produced!
如果我交换 Python 脚本中的最后两行,我不会收到错误,但表格中会出现两条额外的垂直线。
#!/usr/bin/env python3
print(r'11 & 22 & 33 & 44 \\ \hline')
print(r'\multicolumn{4}{|c|}{\cellcolor{lightgray}\textbf{Table section 2}} \\ \hline')
我使用以下方式生成 pdf:latexmk -shell-escape -enable-pipes -pdf -halt-on-error test.tex
我做错了什么?