我有 3 个数字,目前它们排成两行。如何才能将它们强制排成一行?我尝试过更改数字的宽度,但没有什么效果。
\documentclass[11pt]{article}
\usepackage{subfigure}
\usepackage{pgfplots}
\usepackage[top=3cm,left=3cm,right=3cm,bottom=3cm]{geometry}
% Scriptsize axis style.
\pgfplotsset{every axis/.append style={tick label style={/pgf/number format/fixed},font=\scriptsize,ylabel near ticks,xlabel near ticks,grid=major}}
\begin{document}
\begin{figure}[t!]
\centering
\subfigure[Sigmoid]{
\begin{tikzpicture}
\begin{axis}[width=5.5cm,height=4cm,ylabel=$\sigma(z)$,xlabel=$z$,ymin=0,ymax=1.25,xmin=-5,xmax=5]
\addplot[blue,smooth] {1/(1+exp(-x))};
\end{axis}
\end{tikzpicture}
}
\subfigure[Tanh]{
\begin{tikzpicture}
\begin{axis}[width=5.5cm,height=4cm,ylabel=$\tanh(z)$,xlabel=$z$,ymin=-1.25,ymax=1.25,xmin=-5,xmax=5]
\addplot[blue,smooth] {tanh(x)};
\end{axis}
\end{tikzpicture}
}\\
\subfigure[ReLU]{
\begin{tikzpicture}
\begin{axis}[width=5.5cm,height=4cm,ylabel=$s(z)$,xlabel=$z$,ymin=-1,ymax=1.25,xmin=-5,xmax=5]
\addplot[samples=500, blue] {max(0, x)};
%\addlegendentry{ReLU}
\end{axis}
\end{tikzpicture}
}
\end{figure}
\end{document}
致谢大卫·史都兹原始数据。
答案1
为了删除第二张和第三张图片之间的换行符,我删除了\\
makred 行中的 (参见% <------
代码)。我还用subfigure
较新的软件包替换了过时的软件包subfig
,并相应地将命令从 更改为\subfigure
。\subfloat
最后,我稍微减少了 tikspictures 的宽度,以width=5.5cm
确保width=5.25cm
一行中的三张图片适合边距:
\documentclass[11pt]{article}
\usepackage{subfig}
\usepackage{pgfplots}
\usepackage[top=3cm,left=3cm,right=3cm,bottom=3cm]{geometry}
% Scriptsize axis style.
\pgfplotsset{every axis/.append style={tick label style={/pgf/number format/fixed},font=\scriptsize,ylabel near ticks,xlabel near ticks,grid=major}}
\begin{document}
\begin{figure}[t!]
\centering
\subfloat[Sigmoid]{
\begin{tikzpicture}
\begin{axis}[width=5.25cm,height=4cm,ylabel=$\sigma(z)$,xlabel=$z$,ymin=0,ymax=1.25,xmin=-5,xmax=5]
\addplot[blue,smooth] {1/(1+exp(-x))};
\end{axis}
\end{tikzpicture}
}
\subfloat[Tanh]{
\begin{tikzpicture}
\begin{axis}[width=5.25cm,height=4cm,ylabel=$\tanh(z)$,xlabel=$z$,ymin=-1.25,ymax=1.25,xmin=-5,xmax=5]
\addplot[blue,smooth] {tanh(x)};
\end{axis}
\end{tikzpicture}
} %<------------
\subfloat[ReLU]{
\begin{tikzpicture}
\begin{axis}[width=5.25cm,height=4cm,ylabel=$s(z)$,xlabel=$z$,ymin=-1,ymax=1.25,xmin=-5,xmax=5]
\addplot[samples=500, blue] {max(0, x)};
%\addlegendentry{ReLU}
\end{axis}
\end{tikzpicture}
}
\end{figure}
\end{document}