![라텍스 - 루프를 사용하여 나란히 그림](https://rvso.com/image/286998/%EB%9D%BC%ED%85%8D%EC%8A%A4%20-%20%EB%A3%A8%ED%94%84%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EB%82%98%EB%9E%80%ED%9E%88%20%EA%B7%B8%EB%A6%BC.png)
3행 2열에 6개의 숫자를 넣으려고 합니다.
\foreach \x in {1,2,3,4,5,6,7,8,9,10,11,12}
{
\begin{figure}[h]
\caption{This is the caption.}
\vspace{0.0cm} \centering
\includegraphics[height = 5.4cm]{figures/fig\x.eps}
\end{figure}
}
첫 번째 그림 페이지에는 하나의 캡션만 원하고 다음 페이지의 다음 6개 그림에는 동일한 그림 번호를 원합니다.
답변1
나는 결과를 다듬기 위해 pgffor
(또는 ) 패키지, 한 쌍의 사이클(내부 및 외부) 및 여러 조건을 사용했습니다 . tikz
실제 프로젝트에서는 subfigure
두 부분에 대한 클릭 가능한 상호 참조를 얻기 위해 패키지와 두 개의 독립적인 페이지를 사용합니다.
예시와 페이지 미리보기를 동봉합니다. 코드를 성공적으로 컴파일하려면 해당 12개의 그림( fig*
)이 폴더에 저장되어야 합니다 .figures/
%! *latex morepics.tex
\documentclass[a4paper]{article}
\usepackage{pgffor}% or tikz
\usepackage{mwe}
%\usepackage{subfigure}
\begin{document}
\foreach \x in {1,2} {%
\ifnum\x=2\addtocounter{figure}{-1}\fi
\newpage
\begin{figure}%[!ht]
\centering
\caption{This is the caption.}%
\foreach \y in {1,...,6}{%
\pgfmathparse{int((\x-1)*6+\y)}
% We need figures/fig1 to figures/fig12 to be able to compile this particular example.
\includegraphics[height=6.5cm]{figures/fig\pgfmathresult}
\ifnum\y=2\par\fi
\ifnum\y=4\par\fi
}% End of the inner \foreach...
\end{figure}%
}% End of the outer \foreach...
\end{document}
편집하다:패키지 변경 사항: + mwe
, - subfigure
, - tikz
, + pgffor
. 그림 1~6을 사용하고 두 번 사용하는 대신 이제 그림 1~12를 로드합니다.