LaTeX:图形环境中的缩进子标题

时间:2017-07-03 10:16:00

标签: latex indentation figure caption

参见本MWE:

% !TeX spellcheck = en_US
\documentclass[12pt]{article}
\usepackage[onehalfspacing]{setspace}
\usepackage[a4paper, margin=2.5cm]{geometry}
\usepackage{mathptmx}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[hang]{caption}
\usepackage{subcaption} 
\usepackage[bottom]{footmisc}
\usepackage{dcolumn} %makes r output work
\usepackage{tabularx}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} 
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}} 
\newcommand{\possessivecite}[1]{\citeauthor{#1}'s (\citeyear{#1})}
\usepackage{pdfpages}
\usepackage{hyperref}
\usepackage{pdflscape}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{landscape}
    \setcapmargin[2cm]

\begin{figure}[]
    \captionsetup{justification=centering}
    \caption{Main Caption. } 
    \label{fig:val_efcts}
    \begin{subfigure}{0.55\textwidth}
        \caption{X}
        \includegraphics[width=\textwidth] {example-image-a}
    \end{subfigure}
    \begin{subfigure}{0.55\textwidth}
        \caption{Y}
        \includegraphics[width=\textwidth] {example-image-b}
    \end{subfigure}
    \begin{subfigure}{0.55\textwidth}
        \caption{Z}
        \includegraphics[width=\textwidth] {example-image-c}
    \end{subfigure}
    \captionsetup{justification=raggedright}    \subcaption*{This subcaption is supposed to be ragged right and intented by 4 cm. \\ This is in a new line.}
\end{figure}

\end{landscape}

\end{document}

主要应该是不言自明的。我希望图片下面的最后一个子标题是正确的,但是缩进了2厘米。我尝试使用\ setcapmargin,但这不起作用,创建"未定义的控制序列"错误(所以它是一个未知的命令)。

1 个答案:

答案 0 :(得分:0)

由于您正在编写没有编号的标题,请将其设置在\parbox中,您可以更好地控制放置和对齐:

enter image description here

\documentclass{article}

\usepackage{graphicx}
\usepackage[hang]{caption}
\usepackage{subcaption} 

\begin{document}

\begin{figure}[]
    \captionsetup{justification=centering}
    \caption{Main Caption. } 
    \label{fig:val_efcts}
    \begin{subfigure}{0.3\textwidth}
      \caption{X}
      \includegraphics[width=\linewidth] {example-image-a}
    \end{subfigure}\hfill
    \begin{subfigure}{0.3\textwidth}
      \caption{Y}
      \includegraphics[width=\linewidth] {example-image-b}
    \end{subfigure}\hfill
    \begin{subfigure}{0.3\textwidth}
      \caption{Z}
      \includegraphics[width=\linewidth] {example-image-c}
    \end{subfigure}

    \hspace*{4cm}%
    \parbox{\dimexpr\linewidth-8cm}{\raggedright
    \strut This subcaption is supposed to be ragged right and indented by 4cm. \\
    This is in a new line.\strut%
    }
\end{figure}

\end{document}

请注意在处理\strut es内的文本时使用\parbox来支持正确的基线对齐。有关详情,请参阅How to keep a constant baseline skip when using minipages (or \parboxes)?