
\documentclass{minimal}
\usepackage{chngcntr}
\usepackage{pgffor}
\newcounter{question}
\newcounter{answer}
\setcounter{question}{0}
\setcounter{answer}{0}
\newcommand\Que[1]{
\stepcounter{question}}
\newcommand\Ans[2][]{
\stepcounter{answer}}
\newcommand\MAX{10}
\begin{document}
\foreach \i in {1,...,\MAX} {%
\edef\File{ques\i}% The % here are necessary to eliminate any
\edef\FileName{ans\i}% The % here are necessary to eliminate any
\IfFileExists{\FileName}{% spurious spaces that may get inserted
\input{\File}% at these points
\input{\FileName}% at these points
}
}
\end{document}
이것은 내 기본 라텍스 파일의 코드이고 질문과 답변이라는 두 개의 다른 디렉터리가 있습니다. , ... .tex
라는 이름의 질문 디렉터리에는 약 6개의 질문 파일이 있고 ques1
, ... 이라는 이름의 응답 디렉터리에는 ques2
같은 수의 파일이 있습니다 . 위의 for 루프에 디렉터리를 지정하여 위에 언급된 폴더에서 자동으로 파일을 선택하고 싶습니다. 그래서 단일 폴더에 보관할 필요가 없습니다. 또한 i 값 제공을 생략하고 폴더의 모든 파일을 읽을 수 있는 다른 조건을 제공할 수 있는 방법도 있습니다 ..tex
ans1
ans2
.tex