【问题标题】:LaTeX: Indent subcaption in figure environmentLaTeX:图形环境中的缩进子标题
【发布时间】:2017-07-03 10:15:59
【问题描述】:

查看此 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,但这不起作用,创建了“未定义的控制序列”错误(所以它是一个未知的命令)。

【问题讨论】:

  • 您应该将此问题移至TeX SE

标签: latex indentation figure caption


【解决方案1】:

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

\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}

注意在处理\parboxes 中的文本时,使用\struts 来支持正确的基线对齐。有关这方面的更多信息,请参阅How to keep a constant baseline skip when using minipages (or \parboxes)?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多