鉴于此代码,标题未居中。如果标题短得多,则标题居中。我如何使(长)标题居中?
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{figure}[ht]
\hspace*{\fill}
\subcaptionbox{}{
\centering
\begin{tikzpicture}[x=3cm, y=3cm, scale=1.67]
\draw (-.65,0) -- (.65,0);
\end{tikzpicture}
}\hfill
\subcaptionbox{}{
\begin{tikzpicture}[x=3cm, y=3cm, scale=1.67]
\draw (-.15,0) -- (1.15,0);
\end{tikzpicture}
}\hspace*{\fill}
\caption{(a) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\(b) bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}\label{x}
\end{figure}
\end{document}
非常感谢!
答案1
加载caption
包后,我定义了hangcentred
字幕的文本格式:
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.2pt}
\usepackage{caption, eqparbox}
\DeclareCaptionTextFormat{hangcentred}{\eqparbox[t]{CBox}{#1}}
\captionsetup{ style = base, format=hang, textformat = hangcentred}
\begin{document}
\vspace*{1cm}
\begin{figure}[ht]
\hfill
\subcaptionbox{}{
\centering
\begin{tikzpicture}[x=3cm, y=3cm, scale=1.67]
\draw[red, very thick] (-.65,0) -- (.65,0);
\end{tikzpicture}
}\hfill
\subcaptionbox{}{
\begin{tikzpicture}[x=3cm, y=3cm, scale=1.67]
\draw[blue, very thick] (-.15,0) -- (1.15,0);
\end{tikzpicture}
}\hfill\mbox{~}%
\caption{(a) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\(b) bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}\label{x}
\end{figure}
\end{document}