我想从一个单独的文件中读取/输入一个表的主体。但失败了。我该怎么做呢。下面是一个例子
主tex文件:Main.tex
%main.tex
\documentclass{article}
\begin{document}
Table test.
1. Insert a full table
\begin{tabular}{|c|c|}
\hline
a & b \\
\hline
c & d \\
\hline
\end{tabular}
2. Input the body of table from a seperate file
\begin{tabular}{|c|c|}
\input{table}
\end{tabular}
\end{document}表体文件:table.tex
%table.tex
\hline
a & b \\
\hline
c & d \\
\hline 发布于 2014-10-06 16:58:02
在宏中捕获table.tex中的表内容,然后在tabular中处理它。为此,请使用 package

%main.tex
\documentclass{article}
\usepackage{filecontents,catchfile}
\begin{filecontents*}{table.tex}
%table.tex
\hline
a & b \\
\hline
c & d \\
\hline
\end{filecontents*}
\begin{document}
Table test.
1. Insert a full table
\begin{tabular}{|c|c|}
\hline
a & b \\
\hline
c & d \\
\hline
\end{tabular}
2. Input the body of table from a seperate file
\CatchFileDef{\mytable}{table.tex}{}% table.tex > \mytable
\begin{tabular}{|c|c|}
\mytable
\end{tabular}
\end{document}https://stackoverflow.com/questions/26212089
复制相似问题