일부 사진에 캡션이 포함된 부동형 사진 그리드를 얻는 방법

일부 사진에 캡션이 포함된 부동형 사진 그리드를 얻는 방법

이 문제 때문에 정말 고민 중입니다... 약 5,000장의 사진과 텍스트가 포함된 블로그에서 책을 만들고 싶습니다. 나는 블로그에서 얻은 xml 파일에서 유효한 tex 파일을 생성하기 위해 작은 변환기를 작성했습니다.

사진 갯수가 너무 많아서 축소해서 4장까지 연속으로 올리고 싶습니다. 때로는 다음 텍스트 요소가 나타나기 전에 30개 이상의 사진이 있을 수 있습니다. 이 경우 여러 페이지로 확장할 수 있는 사진용 그리드가 있어야 합니다. 텍스트에 실제 참조가 없기 때문에 이미지는 떠다니지 않아야 합니다. 위치에 따라 의미를 알 수 있습니다. 일부 사진에는 표시되어야 하는 캡션이 있습니다.

그래서 이미지 테이블을 생성하려고 시도했지만 "longtable" 패키지를 사용하더라도 테이블을 두 페이지 이상으로 확장할 수 없는 것 같습니다. 그래서 사진의 각 행에 대한 표를 만들려고 했습니다. 진행 중이지만 부동 테이블 형식 환경이 아닌 경우 캡션이 작동하지 않습니다.

이미 여러 옵션을 시도했지만 그 중 어느 것도 내 요구 사항을 모두 충족하지 못하는 것 같습니다.

\begin{center}
\begin{tabular}[c]{cccc}
\includegraphics[width=0.24\textwidth]{D:/Blogfotos3/wpid-p8220063.jpg}\captionof{figure}{Testing}&
\includegraphics[width=0.24\textwidth]{D:/Blogfotos3/wpid-p8220070.jpg}&
\includegraphics[width=0.24\textwidth]{D:/Blogfotos3/wpid-p8220092.jpg}
\end{tabular}
\end{center}

이 솔루션을 사용하면 간격이 꽤 좋아 보이지만 캡션이 작동하지 않습니다.

\begin{figure}[H]
\centering
\begin{subfigure}[t]{0.24\textwidth}\includegraphics[width=\textwidth]{D:/Blogfotos3/wpid-img_7064.jpg}\end{subfigure}
\begin{subfigure}[t]{0.24\textwidth}\includegraphics[width=\textwidth]{D:/Blogfotos3/wpid-dsc5085-edit.jpg}\caption{\centering Scorpionfish}\end{subfigure}
\begin{subfigure}[t]{0.24\textwidth}\includegraphics[width=\textwidth]{D:/Blogfotos3/wpid-dsc5195-edit.jpg}\caption{\centering Schnegge}\end{subfigure}
\begin{subfigure}[t]{0.24\textwidth}\includegraphics[width=\textwidth]{D:/Blogfotos3/wpid-dsc5236.jpg}\caption{\centering Noch ne Schnegge}\end{subfigure}
\end{figure}
\begin{figure}[H]
\centering
\begin{subfigure}[t]{0.24\textwidth}\includegraphics[width=\textwidth]{D:/Blogfotos3/wpid-dsc5178.jpg}\caption{\centering Orang-utan-Crab}\end{subfigure}
\begin{subfigure}[t]{0.24\textwidth}\includegraphics[width=\textwidth]{D:/Blogfotos3/wpid-dsc5022.jpg}\end{subfigure}
\begin{subfigure}[t]{0.24\textwidth}\includegraphics[width=\textwidth]{D:/Blogfotos3/wpid-dsc5139.jpg}\end{subfigure}
\begin{subfigure}[t]{0.24\textwidth}\includegraphics[width=\textwidth]{D:/Blogfotos3/wpid-dsc5251.jpg}\caption{\centering Ghostpipefish}\end{subfigure}
\end{figure}

여기서 캡션은 작동하지만 배치에 어려움을 겪고 있습니다. H를 사용하면 그림이 올바른 위치에 위치하게 되지만 사용되지 않는 공백이 많아 책의 길이가 500페이지를 넘지 않기를 바랍니다 ;-)

내 요구에 맞는 다른 제안이나 패키지가 있습니까?

미리 감사드립니다. 플로

답변1

이렇게 하면 다음과 같은 페이지 목록이 만들어집니다.

여기에 이미지 설명을 입력하세요

저는 \captionof캡션이 있는 항목에만 번호를 매기도록 사용했습니다. 요구 사항에 따라 번호를 모두 지정하거나 지정하지 않도록 쉽게 조정할 수 있습니다.

\documentclass{article}
\usepackage{capt-of,graphicx}
\newcounter{pics}

\newcommand\z[2][]{%
  \ifnum\value{pics}=4\par\setcounter{pics}{1}\else\stepcounter{pics}\fi
  \ifhmode\unskip\hfill\fi
  \parbox[t]{.23\textwidth}{%
   \centering\includegraphics[width=\linewidth]{#2}\par
   \ifx\relax#1\relax\else\captionof{figure}{#1}\fi}}
\errorcontextlines100
\begin{document}
\raggedright
\setlength\parskip{.5cm}
\z[zzz]{example-image}\z[hmmm]{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-a}\z[wwwwheeee]{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-b}
\z{example-image}\z[this...]{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-b}
\z[a caption]{example-image}\z{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-b}
\z{example-image}\z[caption]{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-b}\z{example-image-b}
\z{example-image}\z{example-image-b}\z{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-a}
\z{example-image}\z{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-b}
\z{example-image}\z{example-image-a}\z{example-image-b}


\end{document}

관련 정보