有没有办法可以防止使用时在图形和标题之间添加额外的空间\subfigure
?
我正在使用发布在这个话题其中,\subfigure
使用命令添加\phantomsubfigure
。
使用此命令时,图形和标题之间会添加额外的空间。有没有办法消除这种情况?
这是我的 MWE:
\documentclass[
DIV=11,
%fontsize=12,
twoside=semi,
headinclude=false,
titlepage=firstiscover,
abstract=true,
headsepline=true,
footsepline=true,
chapterprefix=true,
headings=big,
bibliography=totoc,
captions=tableheading
]{scrreprt}
\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm]{geometry}
\usepackage{setspace}
\usepackage{afterpage} %to float a figure onto its own page
\usepackage[draft]{graphicx}
\usepackage[labelformat=empty,skip=0pt]{subcaption}
%%%%%%%%%%% PHANTOM SUBFIGURE COMMAND
% Used for adding subfigure referencing capabilities to composite figure images
\newcommand*\phantomsubfigure[1]{\begin{subfigure}[]{0pt}\caption{}\label{#1}\end{subfigure}} %<---- this is the command
\renewcommand\thesubfigure{(\alph{subfigure})}
\begin{document}
\begin{figure}[htb]
\centering
\includegraphics[width=16cm,height=23cm]{myPictureName.png}
\caption{Figure without subfigures.}
\label{fig:1}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=16cm,height=23cm]{myPictureName.png}
\phantomsubfigure{fig:S01+04-xrd_a}
\phantomsubfigure{fig:S01+04-xrd_b}
\phantomsubfigure{fig:S01+04-xrd_c}
\phantomsubfigure{fig:S01+04-xrd_d}
\phantomsubfigure{fig:S01+04-xrd_e}
\caption{Figure with subfigures.}
\label{fig:2}
\end{figure}
\end{document}
答案1
subfigure
通过反复调用环境,您引入了一些虚假的空格。此环境不应在之后调用\includegraphics
,因此无法处理新行引入的空格。您必须以 结束该行%
。我重新定义了您的,\phantomsubfigure
以防止您在以下所有情况下出现此错误。
% arara: pdflatex
\documentclass[%
,DIV=11
,twoside=semi
,headinclude=false
,headsepline=true
,footsepline=true
,headings=big
]{scrreprt}
\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm]{geometry}
\usepackage[draft]{graphicx}
\usepackage[labelformat=empty,skip=0pt]{subcaption}
\newcommand*\phantomsubfigure[1]{\begin{subfigure}{0pt}\caption{}\label{#1}\end{subfigure}\ignorespaces} % put ignore spaces here...
\renewcommand\thesubfigure{(\alph{subfigure})}
\begin{document}
\begin{figure}[htb]
\centering
\includegraphics[width=16cm,height=23cm]{myPictureName.png}
\caption{Figure without subfigures.}
\label{fig:1}
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=16cm,height=23cm]{myPictureName.png}% <= this one is mandatory
\phantomsubfigure{fig:S01+04-xrd_a}
\phantomsubfigure{fig:S01+04-xrd_b}
\phantomsubfigure{fig:S01+04-xrd_c}
\phantomsubfigure{fig:S01+04-xrd_d}
\phantomsubfigure{fig:S01+04-xrd_e}
\caption{Figure with subfigures.}
\label{fig:2}
\end{figure}
\end{document}