更改已加星标的标题而不影响未加星标的标题

更改已加星标的标题而不影响未加星标的标题

鉴于表格

\documentclass{scrartcl}

\usepackage{booktabs,caption}

\begin{document}

\begin{table}[htb]
    \centering
    \caption{Test table}
    \begin{tabular}{lll}
        \toprule
        abc &   def &   ghi     \\ \midrule
        abc1    &   def2    &   ghi3    \\ \bottomrule
    \end{tabular}
    \caption*{Source: xyz}
\end{table}

\end{document}

如何更改带星号的标题(来自包)前后的空格caption而不影响未带星号的标题?是否可以更改任何(未带星号的)命令而不影响其他命令?

答案1

结合回答我添加了一个命令来更改abovecaptionskipbelowcaptionskip在组内保存之前的长度以及随后恢复它们:

\documentclass{scrartcl}

\usepackage{booktabs}
\usepackage[%
font=small,%
labelfont=bf,%
justification=justified,%
singlelinecheck=false,%
format=plain]{caption}%

\newcommand{\source}[1]{Source: #1}%
\newcommand{\captionskip}[1]{%
    \begingroup%
    \setlength{\abovecaptionskip}{0pt plus 2pt}%
    \setlength{\belowcaptionskip}{0pt plus 2pt}%
    \caption*{\source{#1}}%
    \par\endgroup%
}

\begin{document}
    
    \begin{table}[htb]
        \centering
        \caption{Test table}
        \begin{tabular}{lll}
            \toprule
            abc &   def &   ghi     \\ \midrule
            abc1    &   def2    &   ghi3    \\ \bottomrule
        \end{tabular}
        \captionskip{Test}
    \end{table}
    
\end{document}

相关内容