我正在使用LaTeX 论文模板作者 Matthias Pospiech 不管我怎么尝试 - captionbeside
,minipages
等等 - LaTeX 总是会放置标题以下但是对于某些图形,我希望它们位于图形旁边。
我无法使用 MWE 重现该问题。有人猜出原因是什么吗?我快疯了。如果我注释掉与floatrow
和相关的所有设置,问题仍然存在caption
。
一些例子
清楚的:
\begin{figure}
\includegraphics[width=.6\textwidth]{example-image-a}
\caption{Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus velit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie ut, ultricies vel, semper in, velit.}
\end{figure}
\begin{figure}
\begin{captionbeside}{Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus velit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie ut, ultricies vel, semper in, velit.}[o]
\includegraphics[width=.6\textwidth]{example-image-a}
\end{captionbeside}
\end{figure}
\begin{figure}
\begin{minipage}[t]{0.6\textwidth}
\mbox{}\\[-\baselineskip]
\includegraphics[width=\textwidth]{example-image-a}
\end{minipage}~\hfill~%
\begin{minipage}[t]{0.38\textwidth}
\mbox{}\\[-\baselineskip]
\caption{Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus velit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie ut, ultricies vel, semper in, velit.}
\end{minipage}
\end{figure}
答案1
以下是基于的示例minipage
。从片段中我了解到您更喜欢顶部对齐。
\documentclass{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{ragged2e}
\usepackage{kantlipsum} % For filler text
\usepackage{caption}
\DeclareCaptionFormat{belowlabel}{#1#2}
\captionsetup[figure]{
format=belowlabel,
position=top,
singlelinecheck=false,
skip=6pt,
}
\begin{document}
\kant[1][1]
\begin{figure}[tbh]
\begin{minipage}[t]{0.6\linewidth}
\includegraphics[width=\linewidth,valign=T]{example-image}
\end{minipage}\hfill
\begin{minipage}[t]{\dimexpr0.4\linewidth-1em}
\caption{\null}
\RaggedRight Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus velit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie ut, ultricies vel, semper in, velit.
\end{minipage}
\end{figure}
\kant[2][1]
\end{document}
编辑。
如果此样式必须与普通样式进行干预,则\captionseup
需要在环境内进行局部范围的更改。整个样式可以包含在宏中:
\NewDocumentCommand\Figure{O{} m m}{%
\begin{figure}[#1]
\captionsetup{
format=belowlabel,
position=top,
singlelinecheck=false,
skip=6pt,
}
\begin{minipage}[t]{0.6\linewidth}
\includegraphics[width=\linewidth,valign=T]{#2}
\end{minipage}\hfill
\begin{minipage}[t]{\dimexpr0.4\linewidth-1em}
\caption{\null}
\IfValueT{#3}{\notblank{#3}{\par\RaggedRight #3}{}}
\end{minipage}
\end{figure}}
其他图片将遵循标准样式。查看更新后的代码和屏幕截图
\documentclass{article}
\usepackage{etoolbox}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{ragged2e}
\usepackage{kantlipsum} % For filler text
\usepackage{caption}
\DeclareCaptionFormat{belowlabel}{#1#2}
\NewDocumentCommand\Figure{O{} m m}{%
\begin{figure}[#1]
\captionsetup{
format=belowlabel,
position=top,
singlelinecheck=false,
skip=6pt,
}
\begin{minipage}[t]{0.6\linewidth}
\includegraphics[width=\linewidth,valign=T]{#2}
\end{minipage}\hfill
\begin{minipage}[t]{\dimexpr0.4\linewidth-1em}
\caption{\null}
\IfValueT{#3}{\notblank{#3}{\par\RaggedRight #3}{}}
\end{minipage}
\end{figure}}
\begin{document}
\kant[1][1]
\Figure[tbh]{example-image}{%
Nullam nec mi et neque pharetra sollicitudin.
Praesent imperdiet mi nec ante.
Donec ullamcorper, felis non sodales commodo, lectus velit ultrices augue, a dignissim nibh lectus placerat pede.
Vivamus nunc nunc, molestie ut, ultricies vel, semper in, velit.}
\kant[1][2]
\begin{figure}[tbh]
\centering
\includegraphics[width=0.6\linewidth,valign=T]{example-image}
\caption{%
Nullam nec mi et neque pharetra sollicitudin.
Praesent imperdiet mi nec ante.
Donec ullamcorper, felis non sodales commodo, lectus velit ultrices augue, a dignissim nibh lectus placerat pede.
Vivamus nunc nunc, molestie ut, ultricies vel, semper in, velit.}
\end{figure}
\kant[1][3]
\Figure{example-image-a}{}
\end{document}
答案2
除了 Celdor 的回答之外,我还想为使用上述模板遇到此问题的其他任何人添加第二种更实际的方法:模板使用包floatrow
,可以使用括号在本地更改样式。例如
\documentclass[12pt]{scrartcl}
\usepackage{microtype,graphicx,floatrow,caption,kantlipsum}
\begin{document}
{
\floatsetup[figure]
{style=plain,capposition=beside,objectset=centering,
capbesidewidth=.5\textwidth,capbesideposition=outside,
floatwidth=sidefil}
\captionsetup[figure]{format=plain}
\begin{figure}
\includegraphics[width=.4\textwidth]{example-grid-100x100pt}
\caption{\kant[1][1]}
\end{figure}
}
\begin{figure}
\includegraphics[width=.4\textwidth]{example-grid-100x100pt}
\caption{\kant[1][1]}
\end{figure}
\end{document}