我使用的 latex 模板使用了相当大的侧边距。为了能够正确显示图像,它提供了将图像扩展到该边距的选项,相应的宽度存储在\widefigurewidth
计算为的常量中\def\widefigurewidth{\dimexpr(\marginparwidth + \textwidth + \marginparsep)}
。
然而,它仍然适合图像的标题和文本宽度:
\begin{figure*}[h]
\includegraphics[width=\widefigurewidth]{black.pdf}
\caption{Lorem ipsum ...}
\end{figure*}
Lorem ipsum...
我尝试明确设置标题宽度:
\begin{figure*}[h]
\centering
\captionsetup{width=\widefigurewidth}
\includegraphics[width=\widefigurewidth]{black.pdf}
\caption{Lorem ipsum ...}
\end{figure*}
Lorem ipsum...
显然,框右侧仍有一些固定边距,将其推向左侧。我该如何覆盖它?
答案1
使用minipage
环境并测试图像和标题,textwidth
然后textwidth + marginparsep
最后测试textwidth + marginparsep + marginparwidth
感谢@JohnKormylo——https://tex.stackexchange.com/a/412713/197451
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\begin{document}
\texttt{figure=textwidth}
\def\widefigurewidth{\dimexpr(\textwidth )}
\begin{figure*}[h]
\sbox0{\includegraphics[width=\widefigurewidth, height=2cm]{example-image}}% measure width
\centering
\begin{minipage}{\wd0}
\usebox0
\caption{\lipsum[66]}
\end{minipage}
\end{figure*}
\texttt{figure=textwidth + marginparsep}
\def\widefigurewidth{\dimexpr(\textwidth+\marginparsep)}
\begin{figure*}[h]
\sbox0{\includegraphics[width=\widefigurewidth, height=2cm]{example-image}}% measure width
\centering
\begin{minipage}{\wd0}
\usebox0
\caption{\lipsum[66]}
\end{minipage}
\end{figure*}
\texttt{figure=textwidth + marginparsep + marginparwidth}
\def\widefigurewidth{\dimexpr(\textwidth+\marginparsep+\marginparwidth)}
\begin{figure*}[h]
\sbox0{\includegraphics[width=\widefigurewidth, height=2cm]{example-image}}% measure width
\centering
\begin{minipage}{\wd0}
\usebox0
\caption{\lipsum[66]}
\end{minipage}
\end{figure*}
\end{document}