
垂直方向の間隔については、以前に2つの質問をしました(最初の質問:重複するパーボックスに関する質問; 2番目の質問:重複する表に関する質問)、最後に関連する質問があります。結局のところ、2 番目の質問で私が抱えていた問題は、実際には 1 番目の質問と同じでした。そのため、これが繰り返しになっていて、私が何かを見落としているだけであれば (ほぼ間違いなくその通りです)、事前にお詫び申し上げます。
キャプション付きのフロートの前後に垂直方向のスペースを設けて、すべての行が完全に折りたたまれるようにしたいと考えています。 と を変更してみた結果が下にあります\@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}