更改长图标题中的标签字体

更改长图标题中的标签字体

table和等浮点数figure以及longtable环境不同, 的标题longfigure( 的图形等价物longtable)默认情况下不以粗体显示。 包文档不提供更改和使用的选项

\captionsetup[longfigure]{labelfont=bf}

没有效果。这是我的 MWE:

\documentclass{article}
\usepackage{caption}
\usepackage{longfigure}
\usepackage[english]{babel}
\captionsetup{labelfont=bf,textfont=normalsize}

\begin{document}

\begin{figure}[h]
\centering
\caption{My Figure has a caption that spans the entire textwidth. Exactly like I want to.}\label{fig:figure} 
\rule{3cm}{3cm}
\end{figure}

\begin{longfigure}{cc}
\caption{My Longfigure does not have a bold label and does not span the entire tex width. What's wrong?}\label{fig:longfigure} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{6cm}{3cm} & \rule{6cm}{3cm} \\
\rule{6.3cm}{3cm} & \rule{6.3cm}{3cm} \\
\rule{6cm}{3cm} & \rule{6cm}{3cm} \\
\rule{5cm}{3cm} & \rule{5cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{3cm}{3cm} & \rule{3cm}{3cm} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\end{longfigure}

\end{document}

知道如何调整长图标题的外观和大小吗?

答案1

我不知道这个longfigure包,只是看了一眼。嗯,它主要是longtable\LT@xxx替换为\LF@xxx,当然,还使用figure​​而不是 计数器table

在我看来,这是错误的方法,因为有许多文档类和包知道该longtable包并包含对它的适配,但没有人知道该longfigure包。相反,我建议进行修补longtable,以便它可以使用figure计数器作为table包的替代方案。

猜猜怎么着?我早在 2007 年就这么做了,并将这个补丁集成到了 (lt)caption 包中 ;-)

关键是重新定义新提供的命令\LTcaptype,其中包含 使用的计数器longtable。这也适用于用户定义的新浮点类型:

\documentclass[a4paper]{article}
\usepackage{caption}
\usepackage{longtable}
\usepackage[english]{babel}
\captionsetup{labelfont=bf,textfont=normalsize}

\usepackage{newfloat}
\DeclareFloatingEnvironment{diagram}

\begin{document}

\begin{figure}[h]
\centering
\caption{My Figure has a caption that spans the entire textwidth. Exactly like I want to.}\label{fig:figure} 
\rule{3cm}{3cm}
\end{figure}

\renewcommand\LTcaptype{figure}
\begin{longtable}{cc}
\caption{My Longfigure does have a bold label and does span the entire text width.}\label{fig:longfigure} \\
\rule{1cm}{3cm} & \rule{1cm}{3cm} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\rule{3cm}{3cm} & \rule{3cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{5cm}{3cm} & \rule{5cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{3cm}{3cm} & \rule{3cm}{3cm} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\rule{1cm}{3cm} & \rule{1cm}{3cm} \\
\end{longtable}

\renewcommand\LTcaptype{diagram}
\begin{longtable}{cc}
\caption{My Longdiagram does have a bold label and does span the entire text width.}\label{fig:longdiagram} \\
\rule{1cm}{3cm} & \rule{1cm}{3cm} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\rule{3cm}{3cm} & \rule{3cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{5cm}{3cm} & \rule{5cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{3cm}{3cm} & \rule{3cm}{3cm} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\rule{1cm}{3cm} & \rule{1cm}{3cm} \\
\end{longtable}

\end{document}

(这是一个有文档记录的功能,不幸的是它还没有在caption包文档中提及,而是在ltcaption包文档中提及。)

如果你喜欢拥有一个单独的longfigure环境,可以很容易地通过

\newenvironment{longfigure}
  {\renewcommand\LTcaptype{figure}\longtable}
  {\endlongtable}

完整的示例文档,修改如下:

\documentclass[a4paper]{article}
\usepackage{caption}
\usepackage{longtable}
\usepackage[english]{babel}
\captionsetup{labelfont=bf,textfont=normalsize}

\newenvironment{longfigure}
  {\renewcommand\LTcaptype{figure}\longtable}
  {\endlongtable}

\usepackage{newfloat}
\DeclareFloatingEnvironment{diagram}
\newenvironment{longdiagram}
  {\renewcommand\LTcaptype{diagram}\longtable}
  {\endlongtable}

\begin{document}

\begin{figure}[h]
\centering
\caption{My Figure has a caption that spans the entire textwidth. Exactly like I want to.}\label{fig:figure} 
\rule{3cm}{3cm}
\end{figure}

\begin{longfigure}{cc}
\caption{My Longfigure does have a bold label and does span the entire text width.}\label{fig:longfigure} \\
\rule{1cm}{3cm} & \rule{1cm}{3cm} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\rule{3cm}{3cm} & \rule{3cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{5cm}{3cm} & \rule{5cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{3cm}{3cm} & \rule{3cm}{3cm} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\rule{1cm}{3cm} & \rule{1cm}{3cm} \\
\end{longfigure}

\begin{longdiagram}{cc}
\caption{My Longdiagram does have a bold label and does span the entire text width.}\label{fig:longdiagram} \\
\rule{1cm}{3cm} & \rule{1cm}{3cm} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\rule{3cm}{3cm} & \rule{3cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{5cm}{3cm} & \rule{5cm}{3cm} \\
\rule{4cm}{3cm} & \rule{4cm}{3cm} \\
\rule{3cm}{3cm} & \rule{3cm}{3cm} \\
\rule{2cm}{3cm} & \rule{2cm}{3cm} \\
\rule{1cm}{3cm} & \rule{1cm}{3cm} \\
\end{longdiagram}

\end{document}

相关内容