首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从单独的文件中读取表体?

如何从单独的文件中读取表体?
EN

Stack Overflow用户
提问于 2014-10-06 08:04:34
回答 1查看 8.8K关注 0票数 3

我想从一个单独的文件中读取/输入一个表的主体。但失败了。我该怎么做呢。下面是一个例子

主tex文件:Main.tex

代码语言:javascript
运行
复制
%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

代码语言:javascript
运行
复制
%table.tex
\hline
a & b \\
\hline
c & d \\
\hline 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-06 16:58:02

在宏中捕获table.tex中的表内容,然后在tabular中处理它。为此,请使用 package

代码语言:javascript
运行
复制
%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}
票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26212089

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档