我有一个双倍行距的文档,想在其中放入一个图表。我创建了图表,一切运行正常,直到我尝试放入图形 [H]。
梅威瑟:
\documentclass[letterpaper, 10pt, twoside]{article}
\usepackage{setspace}
\usepackage{pgfplots, filecontents}
\usepackage{float}
\begin{document}
\doublespacing
Figure~\ref{fig:good} shows how I want this to look. Figure~\ref{fig:bad} messes up the tick labels.
\begin{figure}[h]
\centering
\begin{tikzpicture}
\begin{axis}[enlargelimits=false,
axis on top,
axis equal image,
xlabel = {X Info},
ylabel = {Y Info},
xmin = 0,
xmax = 5,
ymin = 0,
ymax = 5,
grid=both,
tick label style={major tick length=0pt},
xtick={1, 2, 3, 4, 5},
xticklabels={1\\\small{Label}, 2\\\small{Label}, 3\\\small{Label}, 4\\\small{Label}, 5\\\small{Label}},
xticklabel style={anchor=north east, align=center},
x label style={yshift=-1em},
ytick={1, 2, 3, 4, 5},
yticklabels={1\\\small{Label}, 2\\\small{Label}, 3\\\small{Label}, 4\\\small{Label}, 5\\\small{Label}},
yticklabel style={anchor=north east, align=center},
y label style={yshift=1em},
]
\end{axis}
\end{tikzpicture}
\caption{Good Figure} \label{fig:good}
\end{figure}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[enlargelimits=false,
axis on top,
axis equal image,
xlabel = {X Info},
ylabel = {Y Info},
xmin = 0,
xmax = 5,
ymin = 0,
ymax = 5,
grid=both,
tick label style={major tick length=0pt},
xtick={1, 2, 3, 4, 5},
xticklabels={1\\\small{Label}, 2\\\small{Label}, 3\\\small{Label}, 4\\\small{Label}, 5\\\small{Label}},
xticklabel style={anchor=north east, align=center},
x label style={yshift=-1em},
ytick={1, 2, 3, 4, 5},
yticklabels={1\\\small{Label}, 2\\\small{Label}, 3\\\small{Label}, 4\\\small{Label}, 5\\\small{Label}},
yticklabel style={anchor=north east, align=center},
y label style={yshift=1em},
]
\end{axis}
\end{tikzpicture}
\caption{Bad Figure} \label{fig:bad}
\end{figure}
\end{document}
如何使用 [H] 位置将标签行间距从第一个数字移到第二个数字?两个数字之间的唯一区别是 [h] 与 [H]。
答案1
setspace
在“真实”浮点数中局部将基线设置回正常状态,但在H
添加时不会\singlespacing
产生相同的布局。
\documentclass[letterpaper, 10pt, twoside]{article}
\usepackage{setspace}
\usepackage{pgfplots, filecontents}
\usepackage{float}
\begin{document}
\doublespacing
Figure~\ref{fig:good} shows how I want this to look. Figure~\ref{fig:bad} messes up the tick labels.
\begin{figure}[h]
\centering
%\showthe\baselineskip
\begin{tikzpicture}
\begin{axis}[enlargelimits=false,
axis on top,
axis equal image,
xlabel = {X Info},
ylabel = {Y Info},
xmin = 0,
xmax = 5,
ymin = 0,
ymax = 5,
grid=both,
tick label style={major tick length=0pt},
xtick={1, 2, 3, 4, 5},
xticklabels={1\\\small{Label}, 2\\\small{Label}, 3\\\small{Label}, 4\\\small{Label}, 5\\\small{Label}},
xticklabel style={anchor=north east, align=center},
x label style={yshift=-1em},
ytick={1, 2, 3, 4, 5},
yticklabels={1\\\small{Label}, 2\\\small{Label}, 3\\\small{Label}, 4\\\small{Label}, 5\\\small{Label}},
yticklabel style={anchor=north east, align=center},
y label style={yshift=1em},
]
\end{axis}
\end{tikzpicture}
\caption{Good Figure} \label{fig:good}
\end{figure}
\begin{figure}[H]\singlespacing
\centering
%\showthe\baselineskip
\begin{tikzpicture}
\begin{axis}[enlargelimits=false,
axis on top,
axis equal image,
xlabel = {X Info},
ylabel = {Y Info},
xmin = 0,
xmax = 5,
ymin = 0,
ymax = 5,
grid=both,
tick label style={major tick length=0pt},
xtick={1, 2, 3, 4, 5},
xticklabels={1\\\small{Label}, 2\\\small{Label}, 3\\\small{Label}, 4\\\small{Label}, 5\\\small{Label}},
xticklabel style={anchor=north east, align=center},
x label style={yshift=-1em},
ytick={1, 2, 3, 4, 5},
yticklabels={1\\\small{Label}, 2\\\small{Label}, 3\\\small{Label}, 4\\\small{Label}, 5\\\small{Label}},
yticklabel style={anchor=north east, align=center},
y label style={yshift=1em},
]
\end{axis}
\end{tikzpicture}
\caption{Bad Figure} \label{fig:bad}
\end{figure}
\end{document}
不相关,但语法{\small Label}
不是\small{Label}
,尽管我把它留在上面。