라텍스 - 루프를 사용하여 나란히 그림

라텍스 - 루프를 사용하여 나란히 그림

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를 로드합니다.

관련 정보