As godbyk mentioned, we created the sidenotes
package for this purpose. Here is a minimal implementation of your example:
\documentclass{book}
\usepackage[paperwidth=170mm, paperheight=240mm, left=42pt, top=40pt, textwidth=280pt, marginparsep=20pt, marginparwidth=100pt, textheight=560pt, footskip=40pt]{geometry}
\usepackage{sidenotes}
\begin{document}
I shall use the word programming to denote the whole activity of design and implementation of programmed solutions. What I am concerned with is the activity of matching some significant part and aspect of an activity in the real world to the formal symbol manipulation that can be done by a program running on a computer. With such a notion it follows directly that the programming activity I am talking about must include the development in time corresponding to the changes taking place in the real world activity being matched by the program execution, in other words program modifications.\sidenote{As a major result of these studies I described programming as a human activity: theory building.}
One way of stating the main point I want to make is that programming in this sense primarily must be the programmers building up knowledge of a certain kind, knowledge taken to be basically the programmers immediate possession, any documentation being an auxiliary, secondary product.
\end{document}
The marginfix
package could be used, which distributes the marginals nicely and, in particular, avoids overlaps.
An example implementation with font size presets and such is caesar_book
. You might be able to change it to your liking: Github sources.
To try it with an updated TeXLive, just change the first line to \documentclass{caesar_book}
instead of book
and delete the two \usepackages
.
Here is another approach. What it does is to check at the end of the document the values of the figure
and table
counters, and add to the .aux
file a boolean flag setting depending on whether these values are zero or positive.
Then you have on next run \iffigures
and \iftables
which allow you to act conditionally.
In the code below, perhaps the \global
are not really needed, I didn't check.
See also a variant at bottom which does not use the figure
/table
counters because they might well be reset to zero due to document sectioning (as pointed out by egreg
in a comment).
\documentclass[10pt,twocolumn]{article}
\usepackage{lipsum}
\usepackage[margin=0.75in]{geometry}
\usepackage{float}
\floatstyle{boxed}
\restylefloat{figure}
\restylefloat{table}
\newif\iffigures
\newif\iftables
\makeatletter
\AtEndDocument {%
\if@filesw
\ifnum\value{figure}=\z@ % no figures
\immediate\write\@mainaux {\global\string\figuresfalse}%
\else
\immediate\write\@mainaux {\global\string\figurestrue}%
\fi
\ifnum\value{table}=\z@ % no tables
\immediate\write\@mainaux {\global\string\tablesfalse}%
\else
\immediate\write\@mainaux {\global\string\tablestrue}%
\fi
\fi
}
\makeatother
% for the purpose of testing
% this will make a MWE without tables
\long\def\IGNORE #1\ENDIGNORE{}
% uncomment to make a MWE with tables
% \let\IGNORE\empty
% \let\ENDIGNORE\empty
\begin{document}
\tableofcontents
%
\iffigures
\addcontentsline{toc}{section}{List of Figures}
\listoffigures
\fi
%
\iftables
\addcontentsline{toc}{section}{List of Table}
\listoftables
\fi
\section{First section}
\lipsum[\inputlineno]
\begin{figure}[H]\centering
\LaTeX\LaTeX
\caption{my figure}
\end{figure}
\lipsum[\inputlineno]
\begin{figure}[H]\centering
\LaTeX\TeX
\caption{another figure}
\end{figure}
\section{Second section}
\lipsum[\inputlineno]
\IGNORE
\begin{table}[H]\centering
\TeX\LaTeX
\caption{my table}
\end{table}
\ENDIGNORE
\lipsum[\inputlineno]
\IGNORE
\begin{table}[H]\centering
\TeX\TeX
\caption{another table}
\end{table}
\ENDIGNORE
\lipsum[\inputlineno]
\end{document}
Here is for a document with figures but no tables:
And if tables are present:
Three compilations needed.
Variant. I don't know to what extent patching \figure
and \table
as here is OK, depends perhaps on float related packages. At the worst I guess doing the patches immediately after \begin{document}
should be enough (at the end of preamble might not be enough if some package does stuff during At Begin Document).
\documentclass[10pt,twocolumn]{article}
\usepackage{lipsum}
\usepackage[margin=0.75in]{geometry}
\usepackage{float}
\floatstyle{boxed}
\restylefloat{figure}
\restylefloat{table}
\newif\iffigures
\newif\iftables
\makeatletter
\let\OLDfigure\figure
\def\figure {\figures@in@document\OLDfigure }
\let\OLDtable\table
\def\table {\tables@in@document\OLDtable }
\def\figures@in@document {%
\immediate\write\@mainaux {\global\string\figurestrue}%
\global\let\figures@in@document\empty
}
\def\tables@in@document {%
\immediate\write\@mainaux {\global\string\tablestrue}%
\global\let\tables@in@document\empty
}
\makeatother
% for the purpose of testing
% this will make a MWE without tables
\long\def\IGNORE #1\ENDIGNORE{}
% uncomment to make a MWE with tables
%\let\IGNORE\empty
%\let\ENDIGNORE\empty
\begin{document}
\tableofcontents
%
\iffigures
\addcontentsline{toc}{section}{List of Figures}
\listoffigures
\fi
%
\iftables
\addcontentsline{toc}{section}{List of Table}
\listoftables
\fi
\section{First section}
\lipsum[\inputlineno]
\begin{figure}[H]\centering
\LaTeX\LaTeX
\caption{my figure}
\end{figure}
\lipsum[\inputlineno]
\begin{figure}[H]\centering
\LaTeX\TeX
\caption{another figure}
\end{figure}
\section{Second section}
\lipsum[\inputlineno]
\IGNORE
\begin{table}[H]\centering
\TeX\LaTeX
\caption{my table}
\end{table}
\ENDIGNORE
\lipsum[\inputlineno]
\IGNORE
\begin{table}[H]\centering
\TeX\TeX
\caption{another table}
\end{table}
\ENDIGNORE
\lipsum[\inputlineno]
\end{document}
Best Answer
This is a
tocdepth
issue. According to lines 67-68 oftufte-book.cls
which also affects
\listoftheorems
You can counter it (pun intended!) by using, for example
as in the MWE below
You can read more about
tocdepth
here, for example: http://en.wikibooks.org/wiki/LaTeX/Document_Structure