我遇到一个问题,使用子浮点会导致对齐错误。下面是一个代码片段和一个左下角有子浮点和没有子浮点的图。如何在不对代码进行重大更改(即使用完全不同的环境)的情况下修复此问题。
\begin{figure*}
\centering
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = green plate};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = green cup};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = table};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = small shelf};
\end{scope}
\end{tikzpicture}\\ \vspace{1mm}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = red cup};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = red cup};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = table};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = table};
\end{scope}
\end{tikzpicture}\\ \vspace{1mm}
\subfloat[]{\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = red cup};
\end{scope}
\end{tikzpicture}}
\subfloat[]{\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = green cup};
\end{scope}
\end{tikzpicture}}
\subfloat[]{\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = table};
\end{scope}
\end{tikzpicture}}
\subfloat[]{\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}}
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = small shelf};
\end{scope}
\end{tikzpicture}}\\
\caption{}
\label{fig:qualitative}
\end{figure*}
编辑:这是 MWE。它使用ieeeconf.cls
可以在此处下载http://ras.papercept.net/conferences/support/files/ieeeconf.zip我无法粘贴内容,因为它太大,会导致页面崩溃。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%2345678901234567890123456789012345678901234567890123456789012345678901234567890
% 1 2 3 4 5 6 7 8
\documentclass[letterpaper, 10 pt, conference]{ieeeconf} % Comment this line out if you need a4paper
%\documentclass[a4paper, 10pt, conference]{ieeeconf} % Use this line for a4 paper
\IEEEoverridecommandlockouts % This command is only needed if
% you want to use the \thanks command
\overrideIEEEmargins % Needed to meet printer requirements.
% The following packages can be found on http:\\www.ctan.org
\usepackage{amssymb} % assumes amsmath package installed
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{float}
\usepackage{subfig}
\title{\LARGE \bf
Preparation of Papers for IEEE Sponsored Conferences \& Symposia*
}
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = green plate};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = green cup};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = table};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = small shelf};
\end{scope}
\end{tikzpicture}\\ \vspace{1mm}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = red cup};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = red cup};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = table};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = table};
\end{scope}
\end{tikzpicture}\\ \vspace{1mm}
\subfloat[$s$ = Set the table for 2 persons \\ $a$ = pick ]{\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = red cup};
\end{scope}
\end{tikzpicture}}
\subfloat[$s$ = Put all cups on the big shelf \\ $a$ = pick]{\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = green cup};
\end{scope}
\end{tikzpicture}}
\subfloat[$s$ = Set the table for 3 persons \\ $a$ = place]{\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = table};
\end{scope}
\end{tikzpicture}}
\subfloat[$s$ = Put jug on small shelf \\ $a$ = place]{\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.22\textwidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\node[scale=0.75,fill=white,thick,draw=red!80] at (0.3,0.1) {$O^{(k)}$ = small shelf};
\end{scope}
\end{tikzpicture}}\\
\caption{}
\label{fig:qualitative}
\end{figure*}
\end{document}
答案1
的代码\subfloat
以 结尾(经过几次扩展之后)\ignorespaces
,因此其后的空间将被吞噬。如果要保留它,则应添加例如一个空组。
\documentclass{article}
\usepackage{graphicx,subfig}
\begin{document}
\begin{figure}
\centering
% space between pictures
\includegraphics[width=.2\linewidth]{example-image}
\includegraphics[width=.2\linewidth]{example-image}
\caption{}
% space is gobbled away
\subfloat[]{\includegraphics[width=.2\linewidth]{example-image}}
\subfloat[]{\includegraphics[width=.2\linewidth]{example-image}}
\caption{}
% empty group reintroduces space
\subfloat[]{\includegraphics[width=.2\linewidth]{example-image}}{}
\subfloat[]{\includegraphics[width=.2\linewidth]{example-image}}
\caption{}
\end{figure}
\end{document}
答案2
您的问题的解决方案是 @campa 在其回答中所说的内容。考虑到这一点,我建议您进行一些额外的更改。
- 为什么不将
subfloat
和中的tikzpicture
所有项目都包含在同一列中? - 使用变量来表示距离。这样,如果您需要更改它们,就不必逐个进行更改。
- 为节点声明一些样式。与上面相同,您无需重复代码,并且更改起来更容易。
- (编辑)
\strut
在标签中添加 s。这可以改善文本的垂直对齐。
像这样:
\documentclass{article}
\usepackage {lipsum}
\usepackage {showframe} % just for this example
\usepackage {subfig}
\usepackage {tikz}
% styles, to avoid repeating the same code in all the nodes
\tikzset
{%
image/.style={anchor=south west,inner sep=0},
label/.style={scale=0.75,fill=white,thick,draw=red!80,anchor=south west}
}
% if you need to change dimensions better not to have to change them one by one, so:
\def\wdt {0.22\textwidth} % width of the figures
\def\vsep{2.2} % vertical distance between figures
\def\lsep{0.1} % label distance (you can define differnt x and y distance)
\begin{document}
\lipsum[1]
\begin{figure}[h]
\centering
\subfloat[]{% we don't want spaces here
\begin{tikzpicture}
\node[image] at (0,0) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep) {\strut$O^{(k)}$ = green plate};
\node[image] at (0,-\vsep) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep-\vsep) {\strut$O^{(k)}$ = red cup};
\node[image] at (0,-2*\vsep) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep-2*\vsep) {\strut$O^{(k)}$ = red cup};
\end{tikzpicture}}{} % <-- see campa's solution
\subfloat[]{%
\begin{tikzpicture}
\node[image] at (0,0) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep) {\strut$O^{(k)}$ = green cup};
\node[image] at (0,-\vsep) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep-\vsep) {\strut$O^{(k)}$ = red cup};
\node[image] at (0,-2*\vsep) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep-2*\vsep) {\strut$O^{(k)}$ = green cup};
\end{tikzpicture}}{}
\subfloat[]{%
\begin{tikzpicture}
\node[image] at (0,0) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep) {\strut$O^{(k)}$ = table};
\node[image] at (0,-\vsep) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep-\vsep) {\strut$O^{(k)}$ = table};
\node[image] at (0,-2*\vsep) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep-2*\vsep) {\strut$O^{(k)}$ = table};
\end{tikzpicture}}{}
\subfloat[]{%
\begin{tikzpicture}
\node[image] at (0,0) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep) {\strut$O^{(k)}$ = small shelf};
\node[image] at (0,-\vsep) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep-\vsep) {\strut$O^{(k)}$ = table};
\node[image] at (0,-2*\vsep) {\includegraphics[width=\wdt]{example-image-a}};
\node[label] at (\lsep,\lsep-2*\vsep) {\strut$O^{(k)}$ = small shelf};
\end{tikzpicture}}
\caption{}
\label{fig:qualitative}
\end{figure}
\lipsum[2]
\end{document}