2014-10-06 2 views
1

Я хочу прочитать/ввести тело таблицы из отдельного файла. Но это провалилось. Как это сделать. Ниже приведен примерКак читать тело таблицы из отдельного файла?

Основной файл текс: 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 
+1

Добро пожаловать в StackOverflow! (La) Вопросы, связанные с TeX, лучше задавать на [tex.se]. Ваш вопрос был помечен так, что он будет перенесен туда. –

ответ

1

Захват содержимого таблицы в 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} 
+0

Большое спасибо. Это просто мое желание. –

Смежные вопросы