2

I'm currently writing my thesis using the tufte-book class, and have been told that captions must go underneath the figures/tables/schemes (I know this goes against the point, but I can't really do anything about that right now, and plan on printing myself a less-ugly version along with the one conforming to the office guidelines).

Using previous questions here, I've been able to define a new environment for pagefigure which re-defines the figure* environment, in order to force the caption below the figure (I've also set this up for table etc.).

As a MWE, the code below shows the additional preamble I've added to get this to work.

\documentclass[a4paper,twoside, symmetric,justified,notoc, nobib]{tufte-book}

\RequirePackage{etoolbox}
\makeatletter
\newif\if@tufte@margtab\@tufte@margtabfalse
\AtBeginEnvironment{margintable}{\@tufte@margtabtrue}
\AtEndEnvironment{margintable}{\@tufte@margtabfalse}
\newcommand{\classiccaptionstyle}{%
    \long\def\@caption##1[##2]##3{%
        \par
        \addcontentsline{\csname ext@##1\endcsname}{##1}%
        {\protect\numberline{\csname the##1\endcsname}{\ignorespaces ##2}}%
        \begingroup
        \@parboxrestore
        \if@minipage
        \@setminipage
        \fi
        \normalsize
        \@makecaption{\csname fnum@##1\endcsname}{\ignorespaces ##3}\par
        \endgroup}
    \long\def\@makecaption##1##2{%
        \vskip\abovecaptionskip
        \sbox\@tempboxa{\@tufte@caption@font##1: ##2}%
        \ifdim \wd\@tempboxa >\hsize
        \@tufte@caption@font\if@tufte@margtab\@tufte@caption@justification\fi##1: ##2\par
        \else
        \global \@minipagefalse
        \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
        \fi
        \vskip\belowcaptionskip}
    %   \setcaptionfont{\normalfont}
    \let\caption\@tufte@orig@caption%
    \let\label\@tufte@orig@label}
\makeatother

\newenvironment{pagefigure}{%
    \begin{figure*}[b!]
    \classiccaptionstyle
  }{\end{figure*}}

\begin{document}

\begin{pagefigure}
  \includegraphics[scale=1]{graphics/example.eps}
  \caption{A Scheme which should take up the full width of the page }
\end{page figure}

\end{document}

What I now need is to be able to define a 'scheme' in addition to a 'figure' or a table.

I thought I might be able to do this by renewing the figurename to scheme, as below, however this messes up the numbering (Scheme 1.1, figure 1.2 rather than scheme 1.1, figure 1.1...).

\renewcommand\figurename{Scheme}

I've also tried defining a new environment, as below, but again this doesn't give the desired numbering.

\newenvironment{pagescheme}{%
    \begin{figure*}[b!]
 \renewcommand\figurename{Scheme}
    \classiccaptionstyle
  }{\end{figure*}}

Any advice on how to do this would be appreciated. Ideally it needs to be by duplicating the pagefigure environment and changing the captioning for anything in that environment. Packages that define a new scheme environment from scatch lose the tufte floating (i.e. they span into the wrong margin uncontrollably).


I realise the obvious solution to this is to use the chemstyle package, but for various reasons this isn't compatible with the tufte document class.

2

How is this:

\documentclass[a4paper,twoside, symmetric,justified,notoc, nobib]{tufte-book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{graphicx}

\usepackage{chemmacros}
\chemsetup{
  modules = {scheme}
}

\makeatletter
\AtBeginDocument{
  \newenvironment{marginscheme}[1][-1.2ex]
    {\@tufte@margin@float[#1]{scheme}}
    {\end@tufte@margin@float}
  \renewenvironment{scheme}[1][htbp]
    {\ifvmode\else\unskip\fi\@tufte@float[#1]{scheme}{}}
    {\end@tufte@float}
  \renewenvironment{scheme*}[1][htbp]%
    {\ifvmode\else\unskip\fi\@tufte@float[#1]{scheme}{star}}
    {\end@tufte@float}
  \renewcommand\listofschemes{%
    \ifthenelse{\equal{\@tufte@class}{book}}%
      {\chapter*{\listschemename}}%
      {\section*{\listschemename}}%
      \@starttoc{los}%
  }
  \let\l@scheme\l@figure
}
\makeatother

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{scheme}
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{An example caption.}
  \label{sch:example}
\end{scheme}

\lipsum[2]

\end{document}

enter image description here

  • It doesnt seem to do what I was looking for (although it does sort out the numbering issue which is great!), I was needed the caption to go below, as I'd re-defined for the pagescheme environment in my MWE. Due to the size of the schemes, they need to take the full-width of the page (i.e. also expand into the margin, which is what figure* is defined as by the tufte-book class). – Adam Jun 18 '17 at 13:11
  • @Chemistry this defines a scheme and scheme* analoguous to the existing figure and figure* in tufte-latex. Any modifcations you did to figure should now be equally possible with the new scheme environment… – clemens Jun 18 '17 at 13:18
  • I think the issue is the same as with the chemstyle issue, the way in which it defines scheme messes with the tufte class, and causes the scheme to now overflow into the wrong margin. I should edit my question to be more clear. – Adam Jun 18 '17 at 13:25
  • @Chemistry the code above produces an exact copy of tufte-latex's figure: the only thing I did was copying the definitions from the source and replaced figure with scheme! – clemens Jun 18 '17 at 13:29
  • Sorry, I'd missed a line when I pasted it across. That works perfectly! (also, I hadn't discovered chemmacros before, just had a browse through the docs and it has a lot of great things). – Adam Jun 18 '17 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.