그림의 수직 정렬

Oct 08 2020

다음 코드를 고려하십시오.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
  \includegraphics[width = \linewidth]{example-image-golden}
\end{figure}
\begin{figure}[htbp]
  \includegraphics[width = \linewidth]{example-image-golden}
\end{figure}
\end{document}

출력은 다음과 같습니다.

내 질문은 첫 번째 그림이 수직으로 중앙에 있지 않은 이유와 매개 변수 를 변경하지 않고htbp 어떻게 중앙에 배치 할 수 있는지 입니다.

답변

1 EladDen Oct 08 2020 at 21:51

가장 쉬운 방법은 그림에 세로 공간을 채우는 것입니다.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
  \vspace{5cm}
  \includegraphics[width = \linewidth]{example-image-golden}
\end{figure}
\begin{figure}[htbp]
  \includegraphics[width = \linewidth]{example-image-golden}
\end{figure}
\end{document}

또 다른, 아마도 더 나은 옵션은 이미지를 \vfill

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\null
\vfill
\begin{figure}[htbp]
  \includegraphics[width = \linewidth]{example-image-golden}
\end{figure}
\vfill

\begin{figure}[htbp]
  \includegraphics[width = \linewidth]{example-image-golden}
\end{figure}
\end{document}

LaTeX에 참조 할 무언가를 제공하려면 처음에 \ null이 필요합니다.

이 현상이 발생 하는 이유 . 페이지 상단에서 아래로 LaTeX 타입 셋 방식과 관련이 있다고 생각합니다. 두 이미지를 추가 \newpage하거나 그 \clearpage사이에 추가 하면 두 번째 이미지도 중앙에 배치되지 않습니다.

첫 페이지는 여기 [h]와 상단 [t]에 그림을 배치하는 일반 페이지입니다. 두 번째 페이지는 그림이 중앙에있는 그림 페이지 [p]입니다. \newpage두 번째 페이지 를 정의 하면 "일반"페이지가되고 그림도 맨 위에 놓이게됩니다.

-- 편집하다 --

가장 좋은 옵션은 페이지 FAQ 에 의존합니다 . 카운터 totalnumber를 0으로 설정하면 각 그림이 첫 번째이고 텍스트에 맞을 수 있더라도 그림 페이지로 푸시됩니다. 또한 float 사이에 매우 큰 간격을 정의하여 fpsep각 float를 자체 페이지로 강제 설정합니다.

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

\setcounter{totalnumber}{0}
\makeatletter
\setlength\@fpsep{\textheight}
\makeatother

\begin{document}
%\lipsum[1-2] %with or without text, the figure will get pushed to a float page

\begin{figure}[htbp]
  \includegraphics[width = \linewidth]{example-image-golden}
\end{figure}


\begin{figure}[htbp]
  \includegraphics[width = \linewidth]{example-image-golden}
\end{figure}
\end{document}

이것은 일종의 해킹입니다. 카운터를 0으로 설정한다는 것은 기본적으로 LaTeX가 숫자를 여기 [h], 상단 [t] 또는 하단 [b]에 넣을 수 없음을 의미합니다. 이것은 같은 페이지에 텍스트와 그림을 가질 수 없기 때문입니다. 모든 Figure가 플로트 페이지로 이동하도록합니다.