I've some troubles with my caption
definition in my Tufte book style document. The caption work perfectly fine for marginfigure
environments while it indent the figure label for figure
, margintable
and table
environments. You can see on the pictures below framed in green what I want as an indent (i.e. nothing) for my caption style and in red what I don't want.
You can find my caption
definition here in my minimal document code under the CAPTION STYLE
comment divider:
\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}
I'm not really familiar with the \def
command but I tried my best to get what I wanted as caption style. Does any of you know how to applied this style without any further indent for all my figure
and table
environments? What seems weird to me is that the style is well applied for all environments but spacings are still wildly added to some. I know that Tufte book captions' are special so I need to use \@tufte@caption
to access their style but should I perform that in other places to access the other environments caption styles too?
I use pdfLaTex
version 2019 as a compiler.
Thanks for your help and sorry for my english :D.