gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 12:39:35 24 4
gpt4 key购买 nike

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

主 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

最佳答案

捕获 table.tex 中的表格内容在宏中处理它之前 tabular .为此,请使用 catchfile package :

enter image description here

%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}

关于input - 如何从单独的文件中读取表体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26212089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com