2014-10-06 2 views
1

테이블의 본문을 별도의 파일에서 읽고 입력하고 싶습니다. 하지만 실패했습니다. 어떻게 할 수 있습니까? 아래는 일례이다별도의 파일에서 표 본문을 읽는 방법은 무엇입니까?

메인 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 
+1

에 오신 것을 환영합니다 :이 경우, catchfile package를 사용! (La) [tex.se]에서 TeX 관련 질문을하는 것이 좋습니다. 귀하의 질문에 깃발이 표시되어 거기에 이전됩니다. –

답변

1

A의 table.tex 테이블 내용을 캡처 매크로를 tabular 내부에서 처리하기 전에 에 StackOverflow에

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

고맙습니다. 그것은 단지 나의 원한 것입니다. –

관련 문제