\captionsetup 为每个子图和图形计数器

\captionsetup 为每个子图和图形计数器

这是我的.tex

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{booktabs} 
\usepackage{arydshln} 
\usepackage[table, svgnames]{xcolor}
\usepackage{geometry} 
\usepackage{tabularx} 
\usepackage{enumitem}
\usepackage{tikz}
\usepackage{float}
\usepackage{lscape} % for landspace environment
\usepackage{xltabular} % longtable + tabularx
\usepackage{adjustbox}
\usepackage{longtable, makecell}
\usepackage{colortbl}% For colored rows in tables
\usepackage{soul}
\usepackage{tikz} % text highlighting
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{float}
\usepackage{alphalph} % extended alphabetical 'numbering'
\usepackage{ltcaption}


          
% Long figure
\newenvironment{longfigure}[2][]{%
  % #1 (optional) is arbitrary code to be executed before the longtable
  % #2 is the column specification
  \renewcommand{\LTcaptype}{figure}%
  \expandafter\def\csname @captype\endcsname{figure}%
  \setcounter{subfigure}{0}%
  \setlength{\LTleft}{0pt}%
  \setlength{\LTright}{0pt}%
  \renewcommand\thesubfigure{\alphalph{\value{subfigure}}}
  
  #1%
  \begin{longtable}{#2}
}{\end{longtable}} 
            

\begin{document}

% works outside long figure...
\captionsetup[subfigure]{justification = centering, singlelinecheck = false}

\begin{figure}
    \centering
    \includegraphics{example-image-duck}
    \caption{Caption}
\end{figure}

\begin{longfigure}[\setlength{\tabcolsep}{0.01333333\textwidth}]{@{}cccc@{}}
  \caption{Empirical Regularities During Currency Crises \label{fig:cc}}
\endfirsthead
  \caption{Empirical Regularities During Currency Crises (continued)}
\endhead

% doesnt work inside...
% \captionsetup[subfigure]{justification = raggedright, singlelinecheck = false}
\begin{subfigure}[t]{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
% \captionsetup[subfigure]{justification = centering, singlelinecheck = false}
\begin{subfigure}[t]{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}[t]{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}[t]{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\

\begin{subfigure}{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} \\

\end{longfigure}


\captionsetup[subfigure]{justification = raggedright, singlelinecheck = false}


\begin{longfigure}[\setlength{\tabcolsep}{0.01333333\textwidth}]{@{}cccc@{}}
  \caption{Empirical Regularities During Currency Crises \label{fig:cc}}
\endfirsthead
  \caption{Empirical Regularities During Currency Crises (continued)}
\endhead

% \captionsetup[subfigure]{justification = raggedright, singlelinecheck = false}
\begin{subfigure}[t]{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
% \captionsetup[subfigure]{justification = raggedright, singlelinecheck = false}
\end{subfigure} &
\begin{subfigure}[t]{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}[t]{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} &
\begin{subfigure}[t]{0.23\textwidth}
\includegraphics[width=\textwidth]{example-image-duck}
\caption{A subfigure}
\end{subfigure} 

\end{longfigure}


\begin{figure}[H]
    \centering
    \includegraphics{example-image-duck}
    \caption{Caption}
\end{figure}


\end{document}

这是输出,其中突出显示了需要修复的问题:

在此处输入图片描述

  1. 我想让这个标题居中。但是放在\captionsetup前面\begin{subfigure}会出错
  2. 我想修复编号。第一个图形有数字 1,第二个图形有数字 2,第三个有数字 5,第四个有数字 8...如何修复?

相关内容