![子图和子标题对齐不佳](https://linux22.com/image/334859/%E5%AD%90%E5%9B%BE%E5%92%8C%E5%AD%90%E6%A0%87%E9%A2%98%E5%AF%B9%E9%BD%90%E4%B8%8D%E4%BD%B3.png)
我有下图,包含三个子图:
我正在使用以下代码来生成它/它们:
\begin{figure}[htbp]%
\tikzstyle{morpho} = [circle,draw,minimum size=1cm,thick,fill=white,font=\tiny]%
\tikzstyle{grouping} = [thick,rounded corners=5pt,fill=#1!20]%
\pgfmathsetmacro{\O}{0.6}%
\pgfmathsetmacro{\P}{1.5}%
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (O) at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=blue]
($(A)+(-\O,\O)$) --($(A)+(\O,\O)$) -- ($(Sa)+(\O,\O)$) --
($(Ss)+(\O,\O)$) -- ($(Ss)+(\O,-\O)$) -- ($(Sa)+(-\O,-\O)$) -- cycle;
\draw[grouping=red]
($(O)+(-\O,\O)$) -- ($(O)+(\O,\O)$) -- ($(O)+(\O,-\O)$) -- ($(O)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A) {Agent};
\node[morpho] at (O) {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Nominative-Accusative}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (O) at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=red]
($(O)+(-\O,\O)$) --($(O)+(\O,\O)$) -- ($(Ss)+(\O,-\O)$) --
($(Sa)+(-\O,-\O)$) -- ($(Sa)+(-\O,\O)$) -- ($(Ss)+(-\O,\O)$) -- cycle;
\draw[grouping=blue]
($(A)+(-\O,\O)$) -- ($(A)+(\O,\O)$) -- ($(A)+(\O,-\O)$) -- ($(A)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A) {Agent};
\node[morpho] at (O) {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Ergative-Absolutive}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}%
\centering
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (O) at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=red]
($(O)+(-\O,\O)$) -- ($(O)+(\O,\O)$) -- ($(O)+(\O,-\O)$) -- ($(O)+(-\O,-\O)$) -- cycle;
\draw[grouping=blue]
($(A)+(-\O,\O)$) -- ($(A)+(\O,\O)$) -- ($(A)+(\O,-\O)$) -- ($(A)+(-\O,-\O)$) -- cycle;
\draw[grouping=green]
($(Sa)+(-\O,\O)$) --($(Ss)+(\O,\O)$) -- ($(Ss)+(\O,-\O)$) -- ($(Sa)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A) {Agent};
\node[morpho] at (O) {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Ergative-Accusative (Tripartite)}
\end{subfigure}
\caption{Morphosyntactic Alignments}
\end{figure}
这样做有几个明显的问题。首先,图画的顶部没有对齐(看起来 LaTeX 是与标题的底部对齐的)。其次,标题本身看起来非常丑陋。对于图 5.1a,在“Nominative-”前面有一个前导空格。对于图 5.1c,我认为文本的布局看起来不太好。而不是
(c) Ergative-Accusative
(Tripartite)
我更喜欢
(c) Ergative-Accusative
(Tripartite)
更新:
因此,感谢一位评论者,我能够找出对齐问题:我忘记了最初复制/粘贴的示例中留下的“b”选项。这是我现在的输出:
我将每个子图的宽度从文本宽度的 0.3 增加到 0.32,这样“主格-宾格”就不再有换行符了。但是,我仍然遇到 5.1c 的问题。它有前导空格,看起来很糟糕,我不知道如何让它对齐,如前所述。我还应该提到我正在使用该subcaption
软件包。
答案1
让我将我的评论转换为答案:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{ragged2e}% <-- added package
\usepackage[justification=RaggedRight,
format=hang]{subcaption}% <-- definition of the subcaption format
\begin{document}
\begin{figure}
\tikzset{% <-- \tikzstyle is replaced by \tikzset
morpho/.style = {circle,draw,thick,
fill=white,minimum size=1cm,
inner sep=2pt,% <-- changed inner sep
font=\scriptsize},% <-- changed font size
grouping/.style = {thick,rounded corners=5pt,fill=#1!20}
}
\pgfmathsetmacro{\O}{0.6}%
\pgfmathsetmacro{\P}{1.5}%
\begin{subfigure}[t]{0.32\textwidth}% <--- increased size of subfigure
\centering
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (O) at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=blue]
($(A)+(-\O,\O)$) --($(A)+(\O,\O)$) -- ($(Sa)+(\O,\O)$) --
($(Ss)+(\O,\O)$) -- ($(Ss)+(\O,-\O)$) -- ($(Sa)+(-\O,-\O)$) -- cycle;
\draw[grouping=red]
($(O)+(-\O,\O)$) -- ($(O)+(\O,\O)$) -- ($(O)+(\O,-\O)$) -- ($(O)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A) {Agent};
\node[morpho] at (O) {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Nominative-Accusative}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.32\textwidth}% <--- increased size of subfigure
\centering
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (O) at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=red]
($(O)+(-\O,\O)$) --($(O)+(\O,\O)$) -- ($(Ss)+(\O,-\O)$) --
($(Sa)+(-\O,-\O)$) -- ($(Sa)+(-\O,\O)$) -- ($(Ss)+(-\O,\O)$) -- cycle;
\draw[grouping=blue]
($(A)+(-\O,\O)$) -- ($(A)+(\O,\O)$) -- ($(A)+(\O,-\O)$) -- ($(A)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A) {Agent};
\node[morpho] at (O) {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Ergative-Absolutive}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.32\textwidth}% <--- increased size of subfigure
\centering
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (O) at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=red]
($(O)+(-\O,\O)$) -- ($(O)+(\O,\O)$) -- ($(O)+(\O,-\O)$) -- ($(O)+(-\O,-\O)$) -- cycle;
\draw[grouping=blue]
($(A)+(-\O,\O)$) -- ($(A)+(\O,\O)$) -- ($(A)+(\O,-\O)$) -- ($(A)+(-\O,-\O)$) -- cycle;
\draw[grouping=green]
($(Sa)+(-\O,\O)$) --($(Ss)+(\O,\O)$) -- ($(Ss)+(\O,-\O)$) -- ($(Sa)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A) {Agent};
\node[morpho] at (O) {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Ergative-Accusative (Tripartite)}
\end{subfigure}
\caption{Morphosyntactic Alignments}
\end{figure}
\end{document}
上述 MWE 给出:
主标题的格式保留为article
文档类中定义的默认设置。可以使用caption
包进行更改。