
나는 수직 간격에 관해 이전에 두 가지 질문을 했습니다(첫 번째 질문:parbox 중복에 대한 질문; 두 번째 질문:겹치는 표에 대한 질문), 마지막 관련 질문이 있습니다. 결과적으로 두 번째 질문의 문제는 실제로 첫 번째 질문과 동일하므로 이것이 반복적이고 뭔가 빠졌을 뿐이라면 미리 사과드립니다(거의 확실히 그렇습니다).
모든 줄이 완벽하게 붕괴되도록 전후에 수직 공간을 갖도록 캡션이 있는 플로트를 얻으려고 합니다. 아래에서 \@caption
및 figure
. 결국, 나는 위의 선과 여전히 불일치하는 상태에서 최종선을 겹치게 만들 수 있었습니다.
\documentclass{article}
\usepackage{color}
\setlength{\abovecaptionskip}{0pt} % set these registers at 0pt to start
\setlength{\belowcaptionskip}{0pt}
\setlength{\intextsep}{0pt}
\begin{document}
\begingroup\centering
\textcolor{red}{Figure 1: Example}
\par\endgroup
\vskip -\baselineskip
\begin{figure}[ht] % the float should be the height of one line?
\caption{Example}
\strut Control Example (red is above, blue is below)
\end{figure}
\vskip -2\baselineskip
\begingroup\centering
\textcolor{blue}{Figure 1: Example}
\par\endgroup
\makeatletter
\long\def\@caption#1[#2]#3{% looking at the definition of caption
\par
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup
\@parboxrestore
\if@minipage
\@setminipage
\fi
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces
\strut #3\strut % added struts
}\par
\endgroup}
\vskip\baselineskip
\begingroup\centering
\textcolor{red}{Figure 2: Example}
\par\endgroup
\vskip -\baselineskip
\begin{figure}[ht]
\caption{Example}
\strut Now the above and below align properly.
\end{figure}
\vskip -2\baselineskip
\begingroup\centering
\textcolor{blue}{Figure 2: Example}
\par\endgroup
\newdimen\keepdepthdim % redefine the figure environment, using the solution from the First Question
\renewenvironment{figure}{\@float{figure}}{%
\par\global\keepdepthdim=\prevdepth
\end@float
\par\prevdepth=\keepdepthdim
}
\makeatother
\vskip\baselineskip
\begingroup\centering
\textcolor{red}{Figure 3: Example}
\par\endgroup
\vskip -\baselineskip
\begin{figure}[ht]
\caption{Example}
\strut Now the bottom line aligns with the caption?
\end{figure}
\vskip -2\baselineskip
\begingroup\centering
\textcolor{blue}{Figure 3: Example}
\par\endgroup
\end{document}
답변1
\caption
기준선 대신 상단과 하단을 정렬하므로 및 겹침에 버팀대를 추가해야 합니다 . .\ht\strutbox+\dp\strutbox=\baselineskip
\documentclass{article}
\usepackage{color}
\setlength{\abovecaptionskip}{0pt} % set these registers at 0pt to start
\setlength{\belowcaptionskip}{0pt}
\setlength{\intextsep}{0pt}
\begin{document}
\begingroup\centering
\textcolor{red}{Figure 1: Example\strut}
\par\endgroup
\vskip -\baselineskip
\begin{figure}[ht] % the float should be the height of one line?
\caption{Example\strut}
%\parbox[t]{\textwidth}{\caption{Example\strut}}\llap{\rule{\textwidth}{0.4pt}}
\strut Control Example (red is above, blue is below)
\end{figure}
\vskip -2\baselineskip
\begingroup\centering
\textcolor{blue}{Figure 1: Example\strut}
\par\endgroup
\end{document}