한 줄에 정렬된 그림과 캡션

한 줄에 정렬된 그림과 캡션

LaTeX에서는 아래 캡션과 함께 두 그림을 나란히 배치하려고 합니다. 캡션의 줄 수가 동일하지 않을 수 있습니다. 이미지는 아래쪽에 정렬되고 캡션은 위쪽에 정렬됩니다.

그림 8, 9, 10, 11floatrow 선적 서류 비치(p 20) 내가 하고 싶은 일을 설명했지만(4개의 그림을 사용하여) 저자는 부분적인 예만 제공하므로 작업을 시작할 수 없습니다.

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

누구든지 문서에 표시된 대로 그림 8, 9, 10, 11을 생성하는 최소 작업 예제를 제공할 수 있습니까? 이미지 파일의 파일 이름으로는 graphics/fig8.png, graphics/fig9.png등을 사용할 수 있습니다. 그리고 그것이 완전한 LaTeX 파일이 될 수 있다면 그것이 바람직할 것이므로 서문도 볼 수 있습니다.

마지막 사항: 저는 이 스타일을 사용하고 있습니다 tufte-book. 가끔 다른 패키지와 충돌이 있는 것 같지만 나중에 알아보겠습니다. :-)

답변1

당신은 잡을 수 있습니다floatrow 선적 서류 비치 암호:

\floatsetup[widefloat]{margins=hangleft}
\begin{figure*}%
  \begin{floatrow}[4]
    \ffigbox
      {\caption{Figure~I in the row (\texttt{floatrow}), ``column'' width}%
      \label{fig:row:Dog}}
      {\input{TheDog.picture}}

    \ffigbox[\FBwidth]
      {\caption{Figure~II in the row (\texttt{floatrow}), graphics width}%
      \label{fig:row:WcatI}}
      {\unitlength1.08\unitlength\input{TheCat.picture}}

    \ffigbox[\Xhsize/2]
      {\caption{Figure~III in the row, float's width box has the
       half of the rest space of row}%
      \label{fig:row:mouse}}
      {{\setlength\unitlength{\hsize/58}%
      {\input{Mouse.picture}}}}

    \ffigbox[\Xhsize]
      {\caption{Figure~IV in the row,
      occupies the rest space of row}%
    \label{fig:row:cheese}}
    {\input{Cheese.picture}}
  \end{floatrow}
\end{figure*}%

사진이 들어있는 곳pictures.tex.

어느 쪽이든, 패키지 없는 접근 방식은 각각을 다음 내부에 설정하는 것입니다 tabular.

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

\documentclass{article}
\usepackage{lipsum,graphicx}

\begin{document}
\sloppy% Just for this example
\lipsum[1]

\begin{figure}[ht]
  \centering
  \begin{tabular}{ p{2.3cm} p{1.5cm} p{2.7cm} p{2.3cm} }
    \includegraphics[width=\linewidth]{example-image} &
    \includegraphics[width=\linewidth]{example-image-a} &
    \includegraphics[width=\linewidth]{example-image-b} &
    \includegraphics[width=\linewidth]{example-image-c}
    \\[\dimexpr-\normalbaselineskip+\abovecaptionskip]
    \caption{First figure in this row of figures} &
    \caption{Second figure in this row of figures} &
    \caption{Third figure} &
    \caption{Last figure that has a very long caption, stretching multiple rows}
  \end{tabular}
\end{figure}

\lipsum[2]

\end{document}

각 이미지 + 캡션은 고정 너비 p열 내에 속하며 각 이미지는 해당 열의 너비로 설정됩니다. 의 키-값 설정에서 이미지를 설정하는 것과 유사합니다 \includegraphics.

이는 이미지가 자연스럽게 기준선에 설정되고 정확히 한 줄을 차지하기 때문에 작동합니다. 또한 내의 각 셀은 -column tabular을 사용하여 설정되며 p, 정렬 앵커는 맨 위 줄의 기준선으로 설정됩니다. 결과적으로 이미지는 아래쪽에 정렬되고 캡션은 위쪽에 정렬됩니다.

필요에 따라 그림과 캡션 사이의 간격을 조정할 수 있습니다. \tabcolsep위의 예에서 기본값인 이미지 사이의 간격도 마찬가지입니다 . 하나는 또한 사용할 수 있습니다tabularx콘텐츠를 펼치거나 텍스트 블록 내에서 늘려서 맞출 수 있습니다.

관련 정보