tikz/pgf/subcaptionbox 中的标题/空格问题

tikz/pgf/subcaptionbox 中的标题/空格问题

我使用 Tikz 绘制了 4 个图表并使用了 subcaptionbox。出现以下问题:(1) 上图的标题与下图之间没有空格。(2) 第二张图 (b) 的标题几乎从左侧 (a) 的标题开始。

为了清楚起见,请参阅附图。

提前致谢问题:在此处输入图片描述 MWE:

\documentclass[paper=a4, fontsize=12pt, open=any, numbers=noenddot]{scrreprt}
\usepackage[utf8x]{inputenc}
\usepackage[a4paper, left=3.5cm, right=2.0cm, top=2.0cm, bottom=2.0cm]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}

\begin{figure}
\subcaptionbox{Dies ist ein Satz, der sehr schlecht umgebrochen wird}{%
\begin{tikzpicture} 
\begin{axis}[xlabel={$t$},ylabel={$y$ [\%]}, xmin=0, xmax=12.8, ymin=-3.0, ymax=5.0, grid, width=7.5cm]
\addplot plot [color=black, mark=no] table{xxx.txt};
\end{axis} 
\end{tikzpicture}}%
\subcaptionbox{Dies ist ein Satz, der sehr schlecht umgebrochen wird}
{
\begin{tikzpicture} 
\begin{axis}[xlabel={$t$},ylabel={$y$[\%]}, xmin=0, xmax=12.8, ymin=-3.0, ymax=5.0, grid, width=7.5cm]
\addplot plot [color=black, mark=no] table{xxx.txt};
\end{axis} 
\end{tikzpicture}
}
\subcaptionbox{Dies ist ein Satz, der sehr schlecht umgebrochen wird}{%
\begin{tikzpicture} 
\begin{axis}[xlabel={$t$},ylabel={$y$ [\%]}, xmin=0, xmax=12.8, ymin=-3.0, ymax=5.0, grid, width=7.5cm]
\addplot plot [color=black, mark=no] table{xxx.txt};
\end{axis} 
\end{tikzpicture}}%
\subcaptionbox{Dies ist ein Satz, der sehr schlecht umgebrochen wird}
{
\begin{tikzpicture} 
\begin{axis}[xlabel={$t$},ylabel={$y$ [\%]}, xmin=0, xmax=12.8, ymin=-3.0, ymax=5.0, grid, width=7.5cm]
\addplot plot [color=black, mark=no] table{xxx.txt};
\end{axis} 
\end{tikzpicture}
}
\caption{Hier ist alles OK Hier ist alles OK Hier ist alles OK Hier ist alles OK Hier ist alles OK }
\label{fig:aaaaa}
\end{figure}

\end{document}

答案1

您可以使用间距命令\hspace\vspace来获得所需的间距。您可以在下面的代码中看到我将它们添加到哪里。请注意,我在此示例中略微缩减了您的序言,特别是,pgfplots已经加载tikz,因此tikz无需单独加载。

\documentclass[paper=a4, fontsize=12pt, open=any, numbers=noenddot]{scrreprt}
\usepackage[a4paper, left=3.5cm, right=2.0cm, top=2.0cm, bottom=2.0cm]{geometry}
\usepackage{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}

\begin{figure}
\subcaptionbox{Dies ist ein Satz, der sehr schlecht umgebrochen wird}{%
\begin{tikzpicture} 
\begin{axis}[xlabel={$t$},ylabel={$y$ [\%]}, xmin=0, xmax=12.8, ymin=-3.0, ymax=5.0, grid, width=7.5cm]
\addplot plot [color=black, mark=no] {x};
\end{axis} 
\end{tikzpicture}}
%
\hspace{1cm}
%
\subcaptionbox{Dies ist ein Satz, der sehr schlecht umgebrochen wird}{%
\begin{tikzpicture} 
\begin{axis}[xlabel={$t$},ylabel={$y$[\%]}, xmin=0, xmax=12.8, ymin=-3.0, ymax=5.0, grid, width=7.5cm]
\addplot plot [color=black, mark=no] {x};
\end{axis} 
\end{tikzpicture}}%
%
\vspace{1cm}
%
\subcaptionbox{Dies ist ein Satz, der sehr schlecht umgebrochen wird}{%
\begin{tikzpicture} 
\begin{axis}[xlabel={$t$},ylabel={$y$ [\%]}, xmin=0, xmax=12.8, ymin=-3.0, ymax=5.0, grid, width=7.5cm]
\addplot plot [color=black, mark=no] {x};
\end{axis} 
\end{tikzpicture}}%
%
\hspace{1cm}
%
\subcaptionbox{Dies ist ein Satz, der sehr schlecht umgebrochen wird}{%
\begin{tikzpicture} 
\begin{axis}[xlabel={$t$},ylabel={$y$ [\%]}, xmin=0, xmax=12.8, ymin=-3.0, ymax=5.0, grid, width=7.5cm]
\addplot plot [color=black, mark=no] {x};
\end{axis} 
\end{tikzpicture}}%
\caption{Hier ist alles OK Hier ist alles OK Hier ist alles OK Hier ist alles OK Hier ist alles OK }
\label{fig:aaaaa}
\end{figure}

\end{document}

在此处输入图片描述

答案2

我花了大约两天的时间寻找解决方案,最终找到了解决我的对齐、格式等问题的秘诀。其中}% \hspacesubcaptionbox。这是我的版本,我希望它能帮助其他想要将图直接添加到 LaTex 代码并排 + 子标题框和正确对齐的用户。

\begin{figure}[H]
\centering
\subcaptionbox{Influence of PZT content on (a) the piezoelectric $d_{33}$ of (b) the dielectric $\epsilon$ of the PZT/PVDF composite\cite{zhang2008structural}}
{
\begin{tikzpicture}[scale=0.9, trim axis left]
\begin{axis}[legend pos=north west, xlabel=PZT contents $Vol\%$, ylabel=$d_{33}$ (pC/N)]
\addplot coordinates {
(3.992E+001,    6.879E+000)
(5.004E+001,    1.287E+001)
(5.992E+001,    1.995E+001)
(7.004E+001,    2.400E+001)
(8.008E+001,    3.093E+001)
};
\addplot coordinates {
(3.992E+001,    1.505E+001)
(5.004E+001,    2.307E+001)
(6.000E+001,    3.396E+001)
(7.004E+001,    4.096E+001)
(8.000E+001,    3.497E+001)
};
\legend{Cold press,Hot press}
\end{axis}
\end{tikzpicture}%
}%
\hspace{1cm}
\subcaptionbox{Influence of PZT content on (a) the piezoelectric $d_{33}$ of (b) the dielectric $\epsilon$ of the PZT/PVDF composite\cite{zhang2008structural}}
{
\begin{tikzpicture}[scale=0.9, trim axis right]
\begin{axis}[legend pos=north west, xlabel=PZT contents $Vol\%$, ylabel=$d_{33}$ (pC/N)]
\addplot coordinates {
(3.992E+001,    6.879E+000)
(5.004E+001,    1.287E+001)
(5.992E+001,    1.995E+001)
(7.004E+001,    2.400E+001)
(8.008E+001,    3.093E+001)
};
\addplot coordinates {
(3.992E+001,    1.505E+001)
(5.004E+001,    2.307E+001)
(6.000E+001,    3.396E+001)
(7.004E+001,    4.096E+001)
(8.000E+001,    3.497E+001)
};
\legend{Cold press,Hot press}
\end{axis}
\end{tikzpicture}%
}
\caption{Potentail diagram of the extraction.}
\label{fig:potential}
\end{figure} 

在此处输入图片描述

相关内容