我在 Tufte 书籍样式文档中的定义遇到了一些问题caption
。标题在环境中工作得很好,但它会缩进、和环境marginfigure
中的图形标签。您可以在下面的图片中看到,绿色框中是我想要的标题样式的缩进(即无缩进),红色框中是我不想要的。figure
margintable
table
您可以在注释分隔符caption
下的我的最小文档代码中找到我的定义CAPTION STYLE
:
\documentclass[justified,notoc,numbers]{tufte-handout}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{xcolor}
\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}
\graphicspath{{graphics/}}
%=======================================================
% FOR DEBUG
%=======================================================
\usepackage{lipsum}
%=======================================================
% FONT STYLE
%=======================================================
\renewcommand{\rmdefault}{ptm}
%=======================================================
% COLORS
%=======================================================
\definecolor{myColor}{rgb}{0.0, 0.5, 1.0}
%=======================================================
% CAPTION STYLE
%=======================================================
\makeatletter
\long\def\@caption#1[#2]#3{%
%
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup%
\@parboxrestore%
\if@minipage%
\@setminipage%
\fi%
\@tufte@caption@font\@tufte@caption@justification%
\colorbox{myColor}{\color{white}\csname fnum@#1\endcsname:} \ignorespaces#3\par%
\endgroup}
\makeatother
%=======================================================
% GEOMETRY
%=======================================================
\geometry{
left=15mm, % left margin
textwidth=140mm, % main text block
headsep=10mm,
headheight = 0mm,
marginparsep=7mm, % gutter between main text block and margin notes
marginparwidth=50mm, % width of margin notes
bottom = 1.5cm,
top = 1.7cm
}
%=======================================================
% HEADER/FOOTER
%=======================================================
\pagestyle{fancy}{
\fancyhf{}
\rhead{Author Name \& Firstname}
\lhead{\textsc{test} - tex.stackexchange.com}
\rfoot{Page \thepage}
}
%=======================================================
% DOCUMENT
%=======================================================
\begin{document}
\begin{marginfigure}
\includegraphics{example-image-a}
\caption{This is a well indent caption as you can see with a multi line caption it is well justified.}
\end{marginfigure}
\begin{margintable}[2cm]
\centering
\begin{tabular}{c|c}
1 & 2 \\
3 & 4
\end{tabular}
\caption{This is \textbf{NOT} a well indent caption as you can see with a multi line caption it is not well justified.}
\end{margintable}
\vspace{9cm} %To make it clear
\begin{figure}
\centering
\includegraphics{example-image-b}
\caption{Once again, this is \textbf{NOT} a well indent caption as you can see with a multi line caption it is not well justified.}
\end{figure}
\begin{table}[!ht]
\centering
\begin{tabular}{c|c}
1 & 2\\
3 & 4
\end{tabular}
\caption{Once again, this is \textbf{NOT} a well indent caption as you can see with a multi line caption it is not well justified.}
\end{table}
\end{document}
我不太熟悉该\def
命令,但我尽力获得了我想要的标题样式。你们中有人知道如何在不进一步缩进的情况下将此样式应用于我的所有figure
环境table
吗?我觉得奇怪的是,该样式适用于所有环境,但某些环境的间距仍然很大。我知道 Tufte 书籍标题很特殊,所以我需要使用它来\@tufte@caption
访问它们的样式,但我是否应该在其他地方执行该操作以访问其他环境的标题样式?
我使用pdfLaTex
2019版本作为编译器。
谢谢您的帮助,抱歉我的英语不好:D。
答案1
缩进是由于 造成的\JustifyingParindent
。
在marginfigure
和margintable
环境中,标题打印有设置justified
和\@tufte@margin@par
。这使得\JustifyingParindent
值为 0.5pc。
请注意,在marginfigure
和margintable
环境中,\caption
不会自动开始新段落。因此,在您的示例中, 的标题前没有缩进marginfigure
,但 的标题前有缩进margintable
( 之前的空行\caption
开始新段落)。
% Paragraph indentation and separation for marginal text
\newcommand{\@tufte@margin@par}{%
\setlength{\RaggedRightParindent}{0.5pc}%
\setlength{\JustifyingParindent}{0.5pt}%
\setlength{\parindent}{0.5pc}%
\setlength{\parskip}{0pt}%
}
在figure
和table
环境中,标题使用设置打印justified
,设置\JustifyingParindent
为值 1.0pc。
% Paragraph indentation and separation for normal text
\newcommand{\@tufte@reset@par}{%
\setlength{\RaggedRightParindent}{1.0pc}%
\setlength{\JustifyingParindent}{1.0pc}%
\setlength{\parindent}{1pc}%
\setlength{\parskip}{0pt}%
}
\@tufte@reset@par
要取消这两种情况下的缩进\caption
,只需将其设置为零即可\JustifyingParindent
。以下几行代码可完成此操作:
\setlength{\JustifyingParindent}{0pt}
\makeatletter
\renewcommand{\@tufte@margin@par}{%
\setlength{\RaggedRightParindent}{0.5pc}%
\setlength{\JustifyingParindent}{0pc}%
\setlength{\parindent}{0.5pc}%
\setlength{\parskip}{0pt}%
}
\makeatother
PS:pc 代表“pica”,1pc = 12pt。