繁体   English   中英

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

[英]LaTeX: Indent subcaption in figure environment

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

由于您要编写的标题没有编号,因此请在\\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}

在处理\\parbox内的文本时,请注意使用\\strut来支持正确的基线对齐。 有关更多信息,请参见使用minipage (或\\parbox es)时如何保持恒定的基线跳过?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM