如何调整图形和表格标签字体的大小?

如何调整图形和表格标签字体的大小?

我使用 \footnotesize 命令缩小了标签字体,但标签的“图 2.1”部分并未调整大小。这意味着我最终得到的是类似这样的内容:“图 2.1:”采用小字体,加上采用原始字体大小的描述。

我怎样才能将“Figure Xi”部分也设置为小字体呢?

答案1

一个简单的解决方案是将您的文档类更改为与您使用的文档类相对应的 KOMA-script 类之一(book=scrbookreport=scrreprtarticle=scrartcl)。然后,您可以使用 KOMA-script 的内置命令来格式化标题。

我在 MWE 中列出了 KOMA-script 的大部分字幕格式命令。我认为您最感兴趣的两个命令是

\addtokomafont{caption}{\footnotesize}
\addtokomafont{captionlabel}{\usekomafont{caption}}

第一行向标题的文本部分添加属性(\caption{<text>}),IE. 花括号内的文字。第二行向标签部分添加字体属性,( Figure 1,Tabell 1 ,ETC.)命令\usekomafont{<fontset>})将为文本部分设置的所有字体属性复制到标签。

如果要从头重置属性,请使用\setkomafont{caption}{<attributes>}, instead of\addtokomafont`。例如,如果您希望标签斜体,但不是文本部分,使用

\addtokomafont{captionlabel}{\usekomafont{caption}\itshape}

以下是 MWE 和输出:

在此处输入图片描述

\documentclass[UKenglish, demo]{scrartcl}
\usepackage{lmodern}
\usepackage{scrlayer-scrpage}
\usepackage[babel=true]{microtype}
\usepackage{babel}
\usepackage{graphicx}
\usepackage{booktabs, bigdelim, rotating}

\KOMAoptions{headings=small,%
            captions=tableheading,%
    }

% Section
\let\raggedsection\flushleft

% Caption and figures
\renewcommand*{\captionformat}{:\ }
\addtokomafont{caption}{\footnotesize}
\addtokomafont{captionlabel}{\usekomafont{caption}}
\setlength{\belowcaptionskip}{0.5\baselineskip}
\setlength{\abovecaptionskip}{0.5\baselineskip}
\setlength{\intextsep}{0.5\baselineskip}

\begin{document}
\title{Capital Asset Prices}
\author{W.\,T.\,F.\,Dull}
\maketitle

\section{Section}
\label{sec:intro}

\textsc{One of the problems} which has plagued the world is bad typesetting of figures and tables. Now we have KOMA-script to help us.

\begin{figure}[!h]
\centering
\includegraphics[width=0.5\columnwidth]{figure1.png}
\caption{A demo of figure captions\label{fig-1}}
\end{figure}

Even table captions look better with KOMA-script, but that is no surprise. The example is borrowed from another question posted at Stackexchange.com

\begin{table}[!htbp]
\caption{A demo of figure captions\label{fig-1}}
\centering

\begin{tabular}{llcc@{}}
\cmidrule[\heavyrulewidth](l){2-4}
& header1 & header 2 & header 3 \\
\cmidrule(l){2-4}
\ldelim\{{4}{4mm}[\parbox{4mm}{\rotatebox[origin=c]{90}{group1}}] & 1 & a & g \\
& 2 & b & h \\
& 3 & c & i \\
& 3 & c & i \\\addlinespace[0.75ex]
\ldelim\{{6}{4mm}[\parbox{4mm}{\rotatebox[origin=c]{90}{group2}}] & 4 & d & j \\
& 5 & e & k \\
& 6 & f & l \\
& 7 & g & m \\
& 8 & h & n \\
& 9 & i & o \\
\cmidrule[\heavyrulewidth](l){2-4}
\end{tabular}
\end{table}
\end{document}

相关内容