如何對齊標題中的文字?

如何對齊標題中的文字?

我想對圖中的幾種技術進行調查。事實證明,有很多技巧,所以我使用了 subcaption 和 subref 來描述這個問題。然而,由於標籤太多,我發現透過使用\\\hspace{textwidth}換行解決方法將每個描述放在一行中很方便。我不想將資訊放在圖像下方的子標題中,因為我不喜歡它,它會破壞整個文件的格式,無論我有子標題,我都會\subref在圖標題中引用其標籤(帶有 ) 。由於子引用標籤使用不同的寬度,標題的左側看起來相當鋸齒狀,有棱角。一個MWE:

\documentclass[oneside,DIV=17]{scrbook}
\usepackage[font={scriptsize,sf},labelfont={scriptsize,sf,bf}]{caption}
\usepackage[subrefformat=parens,labelfont={normalfont,scriptsize,sf},labelsep=space]{subcaption}
\setcapindent{0pt}

\begin{document}
 \begin{figure}
   \subcaptionbox{\label{fig:a}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:b}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:c}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:d}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:e}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:f}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:g}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:h}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:i}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:j}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:k}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \hspace{0.3\textwidth}
   \caption{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus
sem. Nulla et lectus vestibulum urna fringilla ultrices.\\\hspace{\textwidth}
    \subref{fig:a} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:b} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:c} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:d} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:e} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:f} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:g} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:h} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:i} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:j} Short text fit in one line\\\hspace{\textwidth}
    \subref{fig:k} Short text fit in one line
   }
 \end{figure}
\end{document}

它呈現為(紅線,突出顯示問題):

鋸齒狀左邊距

我知道,如果我不對標題文字進行換行,一切都會好起來的。但我認為,讀者可能會發現從列中選擇描述,然後在文字中搜尋標籤項目更容易。感謝您的任何建議。

答案1

我希望您不必在文件中列印帶有此類標題的圖形列表...在這種情況下,請記住使用可選參數\caption

\caption[short caption]{long caption}

這裡有三種選擇。

第一種選擇:

\documentclass[oneside,DIV=17]{scrbook}
\usepackage[font={scriptsize,sf},labelfont={scriptsize,sf,bf}]{caption}
\usepackage[subrefformat=parens,labelfont={normalfont,scriptsize,sf},labelsep=space]{subcaption}
\setcapindent{0pt}

\begin{document}
 \begin{figure}
   \subcaptionbox{\label{fig:a}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:b}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:c}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:d}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:e}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:f}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:g}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:h}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:i}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:j}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:k}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \hspace{0.3\textwidth}
   \caption{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus
sem. Nulla et lectus vestibulum urna fringilla ultrices.\\
    \llap{\subref{fig:a}} Short text fit in one line\\
    \llap{\subref{fig:b}} Short text fit in one line\\
    \llap{\subref{fig:c}} Short text fit in one line\\
    \llap{\subref{fig:d}} Short text fit in one line\\
    \llap{\subref{fig:e}} Short text fit in one line\\
    \llap{\subref{fig:f}} Short text fit in one line\\
    \llap{\subref{fig:g}} Short text fit in one line\\
    \llap{\subref{fig:h}} Short text fit in one line\\
    \llap{\subref{fig:i}} Short text fit in one line\\
    \llap{\subref{fig:j}} Short text fit in one line\\
    \llap{\subref{fig:k}} Short text fit in one line
   }
 \end{figure}
\end{document} 

在此輸入影像描述

第二種選擇:

\documentclass[oneside,DIV=17]{scrbook}
\usepackage[font={scriptsize,sf},labelfont={scriptsize,sf,bf}]{caption}
\usepackage[subrefformat=parens,labelfont={normalfont,scriptsize,sf},labelsep=space]{subcaption}
\setcapindent{0pt}

\begin{document}
 \begin{figure}
   \subcaptionbox{\label{fig:a}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:b}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:c}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:d}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:e}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:f}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:g}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:h}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:i}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:j}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:k}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \hspace{0.3\textwidth}
   \caption{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus
sem. Nulla et lectus vestibulum urna fringilla ultrices.\\
    \protect\makebox[.5cm]{\subref{fig:a}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:b}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:c}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:d}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:e}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:f}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:g}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:h}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:i}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:j}} Short text fit in one line\\
    \protect\makebox[.5cm]{\subref{fig:k}} Short text fit in one line
   }
 \end{figure}
\end{document} 

在此輸入影像描述

第三種選擇:

\documentclass[oneside,DIV=17]{scrbook}
\usepackage[font={scriptsize,sf},labelfont={scriptsize,sf,bf}]{caption}
\usepackage[subrefformat=parens,labelfont={normalfont,scriptsize,sf},labelsep=space]{subcaption}
\setcapindent{0pt}

\begin{document}
 \begin{figure}
   \subcaptionbox{\label{fig:a}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:b}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:c}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:d}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:e}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:f}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:g}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:h}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:i}}{\rule{0.3\textwidth}{0.25\textwidth}}\par
   \subcaptionbox{\label{fig:j}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \subcaptionbox{\label{fig:k}}{\rule{0.3\textwidth}{0.25\textwidth}}\hfill
   \hspace{0.3\textwidth}
   \caption{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus
sem. Nulla et lectus vestibulum urna fringilla ultrices.\\
    \protect\makebox[.5cm][l]{\subref{fig:a}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:b}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:c}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:d}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:e}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:f}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:g}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:h}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:i}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:j}} Short text fit in one line\\
    \protect\makebox[.5cm][l]{\subref{fig:k}} Short text fit in one line
   }
 \end{figure}
\end{document} 

在此輸入影像描述

答案2

使用表格:

\documentclass{article}
\usepackage{lipsum}
\usepackage[font={scriptsize,sf},labelfont={scriptsize,sf,bf}]{caption}
\usepackage[subrefformat=parens,labelfont={normalfont,scriptsize,sf},labelsep=space]{subcaption}

\begin{document}
 \begin{figure}
   \subcaptionbox{\label{fig:a}}{}\hspace{1cm}~
   \subcaptionbox{\label{fig:b}}{}\hspace{1cm}~
   \subcaptionbox{\label{fig:c}}{}\hspace{1cm}~
   \subcaptionbox{\label{fig:d}}{}\hspace{1cm}~
   \subcaptionbox{\label{fig:e}}{}\hspace{1cm}~
   \subcaptionbox{\label{fig:f}}{}\hspace{1cm}~
   \subcaptionbox{\label{fig:g}}{}\hspace{1cm}~
   \subcaptionbox{\label{fig:h}}{}\hspace{1cm}~
   \subcaptionbox{\label{fig:i}}{}\hspace{1cm}~
   \subcaptionbox{\label{fig:j}}{}
   \caption{\protect\lipsum[1]\smallskip
    \protect\tabular{@{}l @{~} l@{}}
    \subref{fig:a} & Short text fit in one line\\
    \subref{fig:b} & Short text fit in one line\\
    \subref{fig:c} & Short text fit in one line\\
    \subref{fig:d} & Short text fit in one line\\
    \subref{fig:e} & Short text fit in one line\\
    \subref{fig:f} & Short text fit in one line\\
    \subref{fig:g} & Short text fit in one line\\
    \subref{fig:h} & Short text fit in one line\\
    \subref{fig:i} & Short text fit in one line\\
    \subref{fig:j} & Short text fit in one line
    \protect\endtabular
   }
 \end{figure}
\end{document}

在此輸入影像描述

相關內容