
我正在從 Stata 匯出一個 LaTeX 表,並使用輸入命令將其新增至文件。但是,我不希望文件顯示該表中的最後一列。表文件將定期重新生成(覆蓋),因此我不想每次都編輯它。有沒有辦法在不編輯表文件本身的情況下不顯示列?
表.tex:
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Table}
\begin{tabular}{l*{3}{cc}}
...
\end{tabular}
\end{table}
主.tex:
\begin{document}
...
\input{table.tex}
...
\end{document}
答案1
您可以臨時修改tabular
以忽略給定的參數並將其替換為其他參數。
檔案temp.tex:
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Table}
\fboxsep=0pt
\fbox{\begin{tabular}{cc}
a & b \\
c & d
\end{tabular}}
\end{table}
測試文檔:
\documentclass{article}
\usepackage{array}
\newcolumntype{H}{>{\setbox0=\hbox\bgroup}c<{\egroup}@{\hspace{-\tabcolsep}}}
\begin{document}
\input{temp.tex}
{% begin group
\let\normaltabular=\tabular
\let\endnormaltabular=\endtabular
\renewenvironment{tabular}[1]{\normaltabular{cH}}{\endnormaltabular}%
\input{temp.tex}
}% end group
\end{document}