From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/sidenotes/README | 3 + macros/latex/contrib/sidenotes/caesar_book.cls | 177 ++++++++ macros/latex/contrib/sidenotes/caesar_example.pdf | Bin 0 -> 75996 bytes macros/latex/contrib/sidenotes/caesar_example.tex | 130 ++++++ macros/latex/contrib/sidenotes/sidenotes.dtx | 504 ++++++++++++++++++++++ macros/latex/contrib/sidenotes/sidenotes.ins | 46 ++ macros/latex/contrib/sidenotes/sidenotes.pdf | Bin 0 -> 218504 bytes 7 files changed, 860 insertions(+) create mode 100644 macros/latex/contrib/sidenotes/README create mode 100644 macros/latex/contrib/sidenotes/caesar_book.cls create mode 100644 macros/latex/contrib/sidenotes/caesar_example.pdf create mode 100644 macros/latex/contrib/sidenotes/caesar_example.tex create mode 100644 macros/latex/contrib/sidenotes/sidenotes.dtx create mode 100644 macros/latex/contrib/sidenotes/sidenotes.ins create mode 100644 macros/latex/contrib/sidenotes/sidenotes.pdf (limited to 'macros/latex/contrib/sidenotes') diff --git a/macros/latex/contrib/sidenotes/README b/macros/latex/contrib/sidenotes/README new file mode 100644 index 0000000000..53e3eb0d53 --- /dev/null +++ b/macros/latex/contrib/sidenotes/README @@ -0,0 +1,3 @@ +This package allows the typesetting of manuscripts with notes, figures, citations, captions and tables in the margin, which is common e.g. in science textbooks or theses. A reference implementation, i.e. the caesar_book class as well as its documentation are included. + +This material is subject to the LaTeX Project Public License. See http://latex-project.org/lppl/lppl-1-3c.html for the details of that license. \ No newline at end of file diff --git a/macros/latex/contrib/sidenotes/caesar_book.cls b/macros/latex/contrib/sidenotes/caesar_book.cls new file mode 100644 index 0000000000..b04a244d91 --- /dev/null +++ b/macros/latex/contrib/sidenotes/caesar_book.cls @@ -0,0 +1,177 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{caesar_book.cls}[2016/04/21 v1.00 Caesar book] +% Load the amsmath and the mhchem package before loading microtype +\RequirePackage{amsmath}% better math handling +\RequirePackage[version=3]{mhchem}% chemical formulas +\LoadClassWithOptions{book}% this is derived from the book class +\RequirePackage{sidenotes}% put annotations, tables and figures in the margin +\captionsetup{font=footnotesize, skip=4pt} +\RequirePackage[maxfloats=45]{morefloats}% a lot of marginals need more float 'memory' +\RequirePackage{marginfix}% automatically adjust the side-floats nicely +\newcommand{\caesar@letterspace}[1]{#1}% allow LuaLaTeX, LaTeX letterspacing +\RequirePackage{microtype}% microtypography +\@ifpackagelater{microtype}{2011/08/18}% xxx allow LaTeX and earlier microtype +{\renewcommand{\caesar@letterspace}[1]{\textls{#1}}}% +{\AtEndDocument{\ClassWarningNoLine{caesar_book}{Need newest microtype for letterspacing.}}} +% +% Set page layout geometry -- default is science-book format +% this means a (portrait) paper size of 170mm x 240mm +% +\RequirePackage{geometry} +\geometry{paperwidth=170mm, paperheight=240mm, left=42pt, top=40pt, textwidth=280pt, marginparsep=20pt, marginparwidth=100pt, textheight=560pt, footskip=40pt} +% +% fontsize is 10pt with a leading (line spacing) of 13pt for book +% +\renewcommand{\normalsize}{\fontsize{10pt}{13pt}\selectfont}% +\renewcommand{\footnotesize}{\fontsize{8pt}{10pt}\selectfont}% +% fullwidth environment, text across textwidth+marginparsep+marginparwidth +\newlength{\overhang} +\setlength{\overhang}{\marginparwidth} +\addtolength{\overhang}{\marginparsep} +% +\newenvironment{fullwidth} + {\ifthenelse{\boolean{@twoside}}% + {\begin{adjustwidth*}{}{-\overhang}}% + {\begin{adjustwidth}{}{-\overhang}}% + }% + {\ifthenelse{\boolean{@twoside}}% + {\end{adjustwidth*}}% + {\end{adjustwidth}}% + } +% set up the fonts +\RequirePackage{ifluatex} +\ifluatex% in LuaLateX we use fontspec + \RequirePackage{fontspec}% + \RequirePackage[vargreek-shape=TeX]{unicode-math}% + \setmathfont{Asana-Math.otf}% asana math works well with palatino + \setmainfont[Ligatures=TeX, Numbers=OldStyle]{Tex Gyre Pagella}% free Palatino clone + \setmonofont{Tex Gyre Cursor}% works okay with palatino + \setsansfont{Tex Gyre Heros}% work okay with palatino + \mhchemoptions{textfontcommand=\addfontfeature{Numbers=Lining}} % use lining numbers for chemical formulas +\else% in LaTeX we load fonts differently + \IfFileExists{mathpazo.sty}{\RequirePackage[osf,sc]{mathpazo}}{}% palatino clone for math + \IfFileExists{helvet.sty}{\RequirePackage[scaled=0.90]{helvet}}{}% helvetica is sans serif font + \IfFileExists{beramono.sty}{\RequirePackage[scaled=0.85]{beramono}}{}% beramono is tt font + \RequirePackage[T1]{fontenc}% finally load fontenc +\fi +% nice headings and TOC +\RequirePackage{titlesec,titletoc}% load the helper package +\setcounter{secnumdepth}{-1}% no numbering at all +\titleformat{\chapter}[display]{\relax\itshape\huge}{}{0pt}{\huge\rmfamily\itshape}[]% chapter format +\titleformat{\section}[hang]{\normalfont\Large\itshape}{}{1em}{}[]% section format +\titleformat{\subsection}[hang]{\normalfont\large\itshape}{}{1em}{}[]% subsection format +\titleformat{\paragraph}[runin]{\normalfont\itshape}{}{1em}{}[]% paragraph format +\renewcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\em #1}% italic description instead of bold) +\setcounter{tocdepth}{0}% The Table of Contents, only chapters +\titlecontents{chapter}% + [0em] % distance from left margin + {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry) + {\hspace*{0em}\contentslabel{2em}} % before w/label (label = ``2'') + {\hspace*{0em}} % before w/o label + {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) + [\end{fullwidth}] % after +%set up header, footer and page numbering +\RequirePackage{fancyhdr}% helper package +\renewcommand{\headrulewidth}{0pt}% The running heads and feet do not have rules +\renewcommand{\footrulewidth}{0pt} +\fancyhf{}% set up the page numbering +{\fancyfoot[LE,RO]{\thepage}} +\fancypagestyle{plain}{% + \fancyhf{} +} +\renewcommand{\frontmatter}{\pagestyle{empty}}% the frontmatter is empty +\renewcommand{\mainmatter}{\cleardoublepage\pagestyle{fancy}}% mainmatter with page numbering +\RequirePackage{ragged2e} % \RaggedRight works better than \raggedright +\newcommand{\marginparstyle}{\footnotesize\RaggedRight} % initialize style with start value +\long\def\@ympar#1{% redefine margin par to avoid too many macros in the document + \@savemarbox\@marbox{\marginparstyle#1}% marginparstyle is a prefix to the marginpar text now + \global\setbox\@currbox\copy\@marbox % the rest of the definition is taken from original LaTeX + \@xympar} +\renewcommand*{\marginfont}{\marginparstyle} +% setup itemize and enumerate +\RequirePackage{enumitem} +\setlist[itemize]{leftmargin=*} +%\renewcommand{\labelitemi}{} +% compatibility with T-L +% +% titlepage +\newcommand{\publisher}[1]{\gdef\caesar@publisher{#1}} +\gdef\caesar@thesis{} +\newcommand{\thesis}[1]{\gdef\caesar@thesis{#1}} +\RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase +\RequirePackage{color} % the title is too black, define gray +\definecolor{darkgray}{rgb}{0.25,0.25,0.25} +\newcommand{\maketitlepage}{% the title page is generated here + % first count the number of lines in the title + \begin{fullwidth} + \raggedright% + \setbox0\vbox{\noindent\fontsize{30}{38}\selectfont\caesar@letterspace{\MakeTextUppercase{\@title}}\par + \count@\z@ + \loop + \unskip\unpenalty\unskip\unpenalty\unskip + \setbox0\lastbox + \ifvoid0 + \xdef\caesar@numlines{\the\count@}% + \else + \advance\count@\@ne + \repeat} + % now adjust the vertical spaces accordingly + \edef\caesar@titlespace{\the\dimexpr 210pt - 15pt * \caesar@numlines \relax}% calculate the necessary space + \cleardoublepage% + \begingroup% + {% + \sffamily% + %\begin{fullwidth}% + \vspace*{0em}% one line extra space + \noindent\LARGE\caesar@letterspace{\MakeTextUppercase{\@author}}\par + \vfill% + \noindent\fontsize{30}{38}\selectfont\textcolor{darkgray}{\caesar@letterspace{\MakeTextUppercase{\@title}}}\par + \vfill% + \vspace{\caesar@titlespace}% + \noindent\Large\caesar@letterspace{\MakeTextUppercase{\caesar@publisher}}\par + %\end{fullwidth}% + }% + \thispagestyle{empty}% + \endgroup + \cleardoublepage% + \begin{center}% + \vspace*{0em}% one line extra space + \textit{\@title}% + \end{center}% + \end{fullwidth}% + \cleardoublepage% + \chapter*{\@title} + \vspace{-3em}% + \section*{\caesar@thesis\@author} + % +} +\newcommand\newthought[1]{% + \addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}% + \noindent\textsc{#1}% +}% +\ExplSyntaxOn +\NewDocumentCommand \sidecite { o o m } +{ + \IfNoValueOrEmptyTF{#1} + { + \IfNoValueOrEmptyTF{#2} + { + \sidenote{\fullcite{#3}} + } + { + \sidenote{\fullcite[#2]{#3}} + } + } + { + \IfNoValueOrEmptyTF{#2} + { + \sidenote{\fullcite[#1]{#3}} + } + { + \sidenote{\fullcite[#1][#2]{#3}} + } + } +} +\ExplSyntaxOff + + diff --git a/macros/latex/contrib/sidenotes/caesar_example.pdf b/macros/latex/contrib/sidenotes/caesar_example.pdf new file mode 100644 index 0000000000..5994080cb9 Binary files /dev/null and b/macros/latex/contrib/sidenotes/caesar_example.pdf differ diff --git a/macros/latex/contrib/sidenotes/caesar_example.tex b/macros/latex/contrib/sidenotes/caesar_example.tex new file mode 100644 index 0000000000..c0f11de77c --- /dev/null +++ b/macros/latex/contrib/sidenotes/caesar_example.tex @@ -0,0 +1,130 @@ +\documentclass{caesar_book} +% +% !BIB TS-program = biber +% +% -- use dummy graphics +\usepackage{mwe} + +%auto generate the bib file +\usepackage{filecontents} +% +\begin{filecontents}{\jobname.bib} +@book{Tufte2006, + author = {Edward R. Tufte}, + title = {Beautiful Evidence}, + year = {2006}, + publisher = {Graphics Press, {LLC}}, + isbn = {0-9613921-7-7} +} + +@book{Tufte1990, + author = {Edward R. Tufte}, + title = {Envisioning Information}, + publisher = {Graphics Press}, + year = {1990}, + isbn = {0-9613921-1-8} +} +\end{filecontents} + +% -- language: English -- +% +\usepackage[english]{babel} +% -- biblatex -- +\usepackage[backend=biber,style=philosophy-classic]{biblatex} % xxx +% the .bib file with the references +\addbibresource{\jobname.bib} + +% Information about the book +% to be put on the title page +\title{Caesar Quick start} +\author{Andy Thomas} +\publisher{Bielefeld University} + +\begin{document} +% no page numbering in front matter +\frontmatter +% generate the title page +\maketitlepage +% show the table of contents +\tableofcontents +% start to number the pages +\mainmatter +% The first chapter with annotation and citations +\chapter{Quick start} +% +We compiled a minimal example file to show the basic use of the caesar class, which allows the typesetting of (science) textbooks or theses. The class itself is a reference implementation of the \emph{sidenotes} package. The package provides the additional functionality\sidenote{namely the use of marginal material such as this note or even figures or tables.} and the class gives sensible default values for page margins, chapter formatting and such. The caesar class is derived from the standard \LaTeX-book class and a little bit of experience with the standard class might be very helpful. In this example, biblatex is used for the references. + +The first pages of the book (the frontmatter) are not numbered, the numbering starts after the \texttt{mainmatter} macro, which is called after the generation of the title page. The layout has ample margins to allow annotations. A main feature and the package is the sidenote, which is a footnote in the margin and can be placed with the \texttt{sidenote} macro.\sidenote{All information is on the same page, no turning of pages is necessary.} It is very similar to \texttt{footnote} and tries to emulate its behavior. The sidenote moves up or down (floats) to not overlap with other floats in the margin and all the sidenotes are subsequently numbered. + +References can be put in the margin as well.\sidecite[For the ideas behind all this, please see:][ and more work by Tufte.]{Tufte1990,Tufte2006} The macro was named \texttt{sidecite} and is defined with two optional parameters (prefix and postfix) similar to \texttt{cite} taken from the biblatex package. The next two sections describe the different options for the use of figures and tables in a document. We start with a couple of figures. +% A section with a couple of figures +\section{Figures} +% +\begin{marginfigure}% + \includegraphics[width=\marginparwidth]{example-image-a}% + \caption{A small rectangle put in the margin.\label{rectangle}}% +\end{marginfigure}% +% +There are three basic options to include figures in a document. The first option is a small figure and its caption in the margin. Figure \ref{rectangle} shows that with a gray rectangle framing the letter \emph{A}. We simply use the \texttt{marginfigure} environment instead of the \texttt{figure} one. + +The next alternative is a figure in the text frame. The figure is placed using the regular \LaTeX-figure environment and its caption, which is displayed in figure~\ref{rectangle2}. +% +\begin{figure}[htbp]% + \includegraphics[height=180pt,width=\textwidth]{example-image-b}% + \caption{A larger rectangle in the main area of the text, i.e.\ it does not span into the margin.}% + \label{rectangle2}% +\end{figure}% +% + +In case that a wider figure is needed, the third option spans over the text as well as the margin area. Here, the common \texttt{figure*} environment can be used. The figure options make it easy to choose the appropriate size for a given input file. +% +\begin{figure*}[htbp] + \includegraphics[height=180pt,width=400pt]{example-image-c}% + \caption{An even larger rectangle. This is the widest figure option. Both, the text as well as the margin width are used for the diagram.} + \label{rectangle3} +\end{figure*} +% + +% Next section with a variety of tables +\section{Tables} +The same set of options (small, normal and wide) are also available for tables. The first option is a small table in the margin, this \texttt{margintable} is shown in table \ref{table1}. +% +\begin{margintable}% + \begin{tabular}{lll}% + A&B&C\\% + 0.50&0.47&0.48\\% + \end{tabular}% + \vspace{2pt} + \caption{A couple of numbers in a table in the margin.\label{table1}}% +\end{margintable}% + +Table \ref{table2} displays a larger table with more numbers. This is done using regular \LaTeX-macros for placing the table along with its caption. +% +\begin{table}[htbp]% + \begin{tabular}{lllllllll}% + A&B&C&D&E&F&G&H&I\\% + 0.50&0.47&0.48&0.50&0.47&0.48&0.60&0.39&1.00\\% + \end{tabular}% + \vspace{2pt}% + \captionsetup{width=\textwidth, justification=justified}% + \caption{A couple of numbers in a larger table. This table spans the usual text width.\label{table2}}% +\end{table}% + +The \texttt{table*} environment is also defined in analogy to \texttt{figure*} and is demonstrated in table \ref{table3}. +% +\begin{table*}[h!] + \begin{tabular}{lllllllllllll}% + A&B&C&D&E&F&G&H&I&J&K&L&M\\% + 0.50&0.47&0.48&0.50&0.47&0.48&0.60&0.39&1.00&0.50&0.47&0.48&0.60\\% + \end{tabular}% + \vspace{2pt} + \caption{Even more numbers in a big table are shown here. This table spans across the full page, text width plus margin.\label{table3}}% +\end{table*} + +% +\section{More information} +\marginpar{It is also possible to put a comment in the margin without a corresponding mark in the text with \texttt{marginpar}.} This is a short example file to show the features of the caesar class together with the sidenotes package. Sometimes it is necessary to compile the document up to 3 times in order to get the alignment of all objects correctly. +% +\printbibliography[heading=bibintoc] + % +\end{document} diff --git a/macros/latex/contrib/sidenotes/sidenotes.dtx b/macros/latex/contrib/sidenotes/sidenotes.dtx new file mode 100644 index 0000000000..aecb8611f6 --- /dev/null +++ b/macros/latex/contrib/sidenotes/sidenotes.dtx @@ -0,0 +1,504 @@ +% \iffalse meta-comment +% +% sidenotes.dtx +% +% Copyright (C) 2011-2014 by Andy Thomas +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2003/12/01 or later. +% +% The author of this work is Andy Thomas +% +%<*driver> +\ProvidesFile{sidenotes.dtx}[2016/04/21 v1.00 rich text in the margin for LaTeX]% +% +%\RequirePackage{l3keys2e}% +%\ProvidesExplPackage{sidenotes}{2016/04/21}{1.00}{rich text in the margin for LaTeX} +%\RequirePackage{marginnote} % provides an offset option for the marginals instead of a float +%\RequirePackage{caption} % handles the captions (in the margin) +%\RequirePackage{xparse} % new LaTeX3 syntax to define macros and environments +%\RequirePackage[strict]{changepage} % Changepage package for symmetric twoside handling +%<*driver> +\documentclass{ltxdoc} +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{sidenotes.dtx} +\PrintIndex + \PrintChanges +\end{document} +% +% \fi +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% +% \GetFileInfo{sidenotes.dtx} +% +% +% \title{The \textsf{sidenotes} package\thanks{This document +% corresponds to \textsf{sidenotes}~\fileversion, dated \filedate. +% Earlier versions by Oliver Schebaum.}} +% \author{Andy Thomas\\ \texttt{andythomas(at)web.de}} +% +% \maketitle +% +% \changes{v0.51}{2011/10/05}{Extent the documentation of the macros.} +% \changes{v0.90}{2012/06/02}{two opt package is required, the definitions are too confusing otherwise} +% \changes{v0.92}{2012/11/09}{corrected typo in email address} +% \changes{v0.95}{2014/01/23}{cleaned up the documentation.} +% \changes{v0.97}{2014/06/05}{make it a expl package} +% \changes{v0.97}{2014/06/05}{introduce package option oneside } +% \changes{v0.98}{2015/03/04}{compatible with new mhchem version} +% \changes{v0.99}{2015/08/10}{no changes (only in caesar-book.cls)} +% \changes{v1.00}{2016/04/21}{no changes, tag v1.0} +% +% \begin{abstract} +% \noindent This package allows the typesetting of rich content in the margin. +% It includes text, but also figures, captions, tables and citations, +% which is common in science textbooks such as Feynman's +% \textit{Lectures on Physics}. +% \end{abstract} +% +% \tableofcontents +% +% \changes{v0.2}{2011/08/21}{Initial version} +% \changes{v0.7}{2011/11/09}{rewrite without optional offsets} +% \changes{v0.91}{2012/06/03}{deleted marginfullcite} +% +% \section{Usage} +% +% \DescribeMacro{\sidenote} +% The macro is very similar to the footnote macro and tries to emulate +% its behavior. It just puts the notes in the margin instead of the bottom +% of the page, therefore the name \emph{sidenote}. It has the same parameters +% as footnote as well as an additional offset: +% \verb+\sidenote[number][offset]{text}+. All the sidenotes are subsequently +% numbered and float in the margin to avoid overlap. +% The first, optional parameter will manually change the numbering to the given +% value. The second offset parameter will fix the text at a certain position +% in the margin. In particular, there is a difference between not providing an +% offset (floating text) and an offset of 0 (fix text at actual position). +% +% \DescribeMacro{\sidenotemark} +% Sidenote tries to mimic the footnote behavior and, consequently, provides the +% same solutions. Sometimes, it is not possible to directly call a sidenote +% macro, e.g.\ inside of a figure caption. Then, you can use +% \verb+\sidenotemark[number]+ and \verb+\sidenotetext[number][offset]{text}+ +% macros. \verb+\sidenotemark+ puts a mark at the current position. Afterwards, +% outside of the environment that causes the trouble, +% \DescribeMacro{\sidenotetext} +% it is possible the call \verb+\sidenotetext[number][offset]{text}+ to provide +% the text and typeset the sidenote. The optional parameters are similar to the +% sidenote macro. The first, optional parameter will change the numbering and +% the offset will change the position. +% +% \changes{v0.61}{2011/10/17}{documentation of sidetext} +% +%\DescribeMacro{\sidecaption} +% The \verb+\sidecaption[entry][offset]{text}+ macro can be used if the caption +% of a figure or table should be in the margin. The caption has to be adjacent +% to the figure, so a float is not an option here. Therefore, the caption might +% overlap with other marginals. Then, these marginals have to be adjusted with +% offset parameters. The formatting of the caption is done by the \emph{caption} +% package by defining a \emph{sidecaption} style. Please refer to the +% documentation of the caption package for information on styles. The macro can +% be starred, which is analog to the regular starred caption (no numbering, no +% tof entry): \verb+\sidecaption*[offset]{text}+. +% +% \DescribeEnv{marginfigure} +% The marginfigure environment puts a figure and its caption in the margin. +% Instead of \verb+\begin{figure}[htbp]+ use \verb+\begin{marginfigure}[offset]+. +% Again, using an offset value switches the behavior from float to fixed +% position. The marginfigure has its own caption style named \emph{marginfigure}. +% +% \DescribeEnv{margintable} +% The margintable environment works similar to marginfigure, but with table +% environments. Use \verb+\begin{margintable}[offset]+ instead of +% \verb+\begin{table}[htbp]+, its caption style is named \emph{margintable}. +% +% \DescribeEnv{figure*} +% The \verb+figure*+ environment is used to position figures across the full +% page, i.e. the text width plus the margin. The algorithm has to distinguish +% between recto and verso (left and right) pages and might need up to three +% \LaTeX{} runs to provide the desired result. The corresponding caption style +% is called \emph{widefigure}. +% \DescribeEnv{table*} +% The sister environment for tables is \verb+table*+. Use \emph{widetable} to +% change its caption style. +% +% \section{Technical note} +% +% When writing the package, we tried to provide a \emph{minimum} extension to +% standard \LaTeX{} for typesetting rich content in the margin. This means, +% that there are no sensible default values for most things such as page +% geometry, fonts and font sizes. However, the \emph{caesar\textunderscore +% book}-class accompanies this package as an example implementation as well +% as a template we use for our theses. +% +% In addition, we tried to keep compatibility with +% packages the user might want to use later. However, the following packages +% are needed by \emph{sidenotes} and might introduce side effects with other +% packages. +% +% \section{Required packages} +% +% \changes{v0.52}{2011/10/06}{added a section that the package needs marginnote, caption and xifthen.} +% \changes{v0.90}{2012/06/02}{added a section that the package needs twoopt and changepage.} +% \changes{v0.94}{2014/01/22}{start using xparse} +% \changes{v0.97}{2014/06/05}{start using l3keys2e} +% +% \begin{description} +% \item[marginnote] +% supports an alternative to \verb+\marginpar+ and creates notes in the +% margin. The notes are not floats and can be shifted up or down. +% Technically, every time an offset is provided the package uses +% \verb+\marginnote+ and \verb+\marginpar+ otherwise. +% \item[caption] +% allows to set figure and table captions in the margin and allows +% easier formatting of these captions. Please refer to the +% \emph{caption} manual for details on styles. +% \item[xparse] is used to take advantage of the improved \LaTeX3 syntax. +% All macros and environments are defined using this package. +% \item[l3keys2e] provides a key/value mechanism +% \item[changepage] is used to correctly shift figure* and table*. It has +% to use the option [strict] to work properly. This might lead to an +% option clash, if the same package is loaded without this option. +% \end{description}% +% +% \section{Implementation} +% +% \iffalse +%<*package> +% \fi +% +% Process the package options: onside +% +% \begin{macrocode} +\ExplSyntaxOn +% +\keys_define:nn { sidenotes } + { + oneside .bool_set:N = \sidenotes_oneside + } +\ProcessKeysOptions { sidenotes } +% \end{macrocode} +% +% \changes{v0.91}{2012/06/03}{sidenotetextstyle is not needed any more} +% \changes{v0.94}{2014/01/22}{change sidenote counter behavior} +% +% We need a counter similar to the footnote counter. +% +% \begin{macrocode} +\newcounter{sidenote} % make a counter +\setcounter{sidenote}{1} % init the counter +% \end{macrocode} +% +% \noindent The \LaTeX3 parts concerning the optional arguments should not +% distinguish between an empty bracket pair and no optional +% argument. This is required to keep macros with two leading +% optional arguments. +% +% \begin{macrocode} +\DeclareExpandableDocumentCommand{\IfNoValueOrEmptyTF}{ m m m } +{ + \IfNoValueTF{#1} + {#2} + {\tl_if_empty:nTF {#1} {#2} {#3}} +} +% \end{macrocode} +% +% \changes{v0.93}{2012/04/17}{regular ifnextchar gobbles trailing whitespaces, introduce a new one that does not.} +% \changes{v0.97}{2014/05/29}{New mechanism to detect subsequent sidenotemarks} +% \changes{v0.97}{2014/06/05}{New macro to place the superscript mark} +% +% \noindent Put a marker in the horizontal list to detect subsequent sidenotemarks. +% +% \begin{macrocode} +\NewDocumentCommand \@sidenotes@thesidenotemark { m } +{ + \leavevmode + \ifhmode + \edef \@x@sf {\the \spacefactor } + \nobreak + \fi + \hbox {\@textsuperscript {\normalfont #1 }} + \ifhmode + \spacefactor \@x@sf + \fi + \relax +} +% +\NewDocumentCommand \@sidenotes@multisign { } {3sp} +% +\NewDocumentCommand \@sidenotes@multimarker { } +{ + \kern-\@sidenotes@multisign + \kern\@sidenotes@multisign\relax +} +% +\NewDocumentCommand \@sidenotes@multichecker { } +{ + \dim_compare:nNnTF \lastkern = \@sidenotes@multisign + {\@sidenotes@thesidenotemark{,}} + {} +} +% +% \end{macrocode} +% +% \changes{v0.97}{2014/05/27}{introduce an internal macro to place the marginal text} +% +% \noindent Introduce an internal macro to place the marginal text. Use +% margin note in case an offset is given and marginpar otherwise. +% +% \begin{macrocode} +\NewDocumentCommand \@sidenotes@placemarginal { m m } +{ + \IfNoValueOrEmptyTF{#1} + {\marginpar{#2}} + {\marginnote{#2}[#1]} +} +% +% \end{macrocode} +% +% \begin{macro}{\sidenote} +% +% Introduce the \verb+\sidenote+ macro with two optional +% arguments to set the number and the offset. +% +% \changes{v0.53}{2011/10/07}{bugfix, now optional number and offset possible} +% \changes{v0.80}{2011/11/10}{unstar the newcommand.} +% \changes{v0.81}{2011/11/29}{added a comma between subsequent sidenotes} +% \changes{v0.90}{2012/06/02}{add optional offset for sidenote} +% \changes{v0.93}{2012/04/17}{removed mandatory whitespace, new ifnextchar takes care of that} +% \changes{v0.94}{2014/01/11}{use xparse syntax} +% +% \begin{macrocode} +\NewDocumentCommand \sidenote { o o +m } +{ + \sidenotemark[#1] + \sidenotetext[#1][#2]{#3} + \@sidenotes@multimarker +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sidenotemark} +% +% Sidenotemark is supposed to work similarly to footnotemark. +% +% \changes{v0.94}{2014/01/11}{use xparse syntax, change counter behavior} +% \changes{v0.96}{2014/02/14}{increase the sidenote counter in sidenotetext now} +% +% \begin{macrocode} +\NewDocumentCommand \sidenotemark { o } +{ + \@sidenotes@multichecker + \IfNoValueOrEmptyTF{#1} + {\@sidenotes@thesidenotemark{\thesidenote}} + {\@sidenotes@thesidenotemark{#1}} + \@sidenotes@multimarker +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sidenotetext} +% +% Sidenotetext is supposed to work similarly to footnotetext. The additional, +% optional argument sets the offset. +% +% \changes{v0.80}{2011/11/10}{unstar the newcommand.} +% \changes{v0.90}{2012/06/02}{add optional offset for sidenotetext} +% \changes{v0.93}{2012/04/17}{add missing comment marks} +% \changes{v0.94}{2014/01/11}{use xparse syntax, change counter behavior} +% +% \begin{macrocode} +\NewDocumentCommand \sidenotetext { o o +m } +{ + \IfNoValueOrEmptyTF{#1} + { + \@sidenotes@placemarginal{#2}{\textsuperscript{\thesidenote}{}~#3} + \refstepcounter{sidenote} + } + {\@sidenotes@placemarginal{#2}{\textsuperscript{#1}~#3}} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sidecaption} +% +% \changes{v0.91}{2012/06/03}{sidecaption* accompanies sidecaption} +% \changes{v0.94}{2014/01/22}{use xparse syntax} +% +% Sidecaption puts the caption in the margin. It never floats with the other +% text in the margin, since it has to be next to the figure. +% Sidecaption* works similarly to sidecaption, but without an entry. +% +% \begin{macrocode} +\DeclareCaptionStyle{sidecaption}{font=footnotesize} +\NewDocumentCommand \sidecaption {s o o m} +{ + \captionsetup{style=sidecaption} + \IfBooleanTF{#1} + { % starred + \IfNoValueOrEmptyTF{#2} + {\marginnote{\caption*{#4}}} + {\marginnote{\caption*{#4}}[#2]} + } + { % unstarred + \IfNoValueOrEmptyTF{#2} + {\def\@sidenotes@sidecaption@tof{#4}} + {\def\@sidenotes@sidecaption@tof{#2}} + \IfNoValueOrEmptyTF{#3} + {\marginnote{\caption[\@sidenotes@sidecaption@tof]{#4}}} + {\marginnote{\caption[\@sidenotes@sidecaption@tof]{#4}}[#3]} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{marginfigure} +% +% \changes{v0.3}{2011/09/29}{define the sidefigure enviroment without the environ package} +% \changes{v0.90}{2012/06/02}{the optional offset parameter is back, renamed environment from sidefigure to marginfigure} +% \changes{v0.94}{2014/01/22}{use xparse syntax} +% +% The marginfigure environment is similar to the figure environment. But the +% figure is put in the margin. +% +% \begin{macrocode} +\newsavebox{\@sidenotes@marginfigurebox} +\DeclareCaptionStyle{marginfigure}{font=footnotesize} +\NewDocumentEnvironment{marginfigure} { o } +{ + \begin{lrbox}{\@sidenotes@marginfigurebox} + \begin{minipage}{\marginparwidth} + \captionsetup{type=figure,style=marginfigure} +} +{ + \end{minipage}% + \end{lrbox}% + \@sidenotes@placemarginal{#1}{\usebox{\@sidenotes@marginfigurebox}} +} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{margintable} +% +% \changes{v0.4}{2011/09/30}{define the sidetable enviroment without the environ package} +% \changes{v0.90}{2012/06/02}{the optional offset parameter is back, renamed environment from sidetable to margintable} +% \changes{v0.94}{2014/01/22}{use xparse syntax} +% +% The margintable is similar to the table environment. But the table +% is put in the margin. +% +% \begin{macrocode} +\newsavebox{\@sidenotes@margintablebox} +\DeclareCaptionStyle{margintable}{font=footnotesize} +\NewDocumentEnvironment{margintable} { o } +{ + \begin{lrbox}{\@sidenotes@margintablebox} + \begin{minipage}{\marginparwidth} + \captionsetup{type=table,style=margintable} +} +{ + \end{minipage} + \end{lrbox} + \@sidenotes@placemarginal{#1}{\usebox{\@sidenotes@margintablebox}} +} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{figure*} +% +% \changes{v0.85}{2011/06/01}{added the figure* environment} +% \changes{v0.97}{2014/05/27}{use adjustwidth in figure* environment} +% +% The figure* environment provides a figure environment for figures that +% span across the full page (text plus margin width). +% +% \begin{macrocode} +\AtBeginDocument{% +\newlength{\@sidenotes@extrawidth} +\setlength{\@sidenotes@extrawidth}{\marginparwidth} +\addtolength{\@sidenotes@extrawidth}{\marginparsep}} +% +\NewDocumentEnvironment{autoadjustwidth}{ m m }% +{ + \bool_if:NTF \sidenotes_oneside + { + \begin{adjustwidth}{#1}{#2} + } + { + \begin{adjustwidth*}{#1}{#2} + } +} +{ + \bool_if:NTF \sidenotes_oneside + { + \end{adjustwidth} + } + { + \end{adjustwidth*} + } +} +% +\DeclareCaptionStyle{widefigure}{font=footnotesize} +\RenewDocumentEnvironment{figure*}{ O{htbp} } +{ + \begin{figure}[#1] + \begin{autoadjustwidth}{}{-\@sidenotes@extrawidth} + \captionsetup{style=widefigure} +} +{ + \end{autoadjustwidth} + \end{figure} +} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{table*} +% +% \changes{v0.85}{2011/06/01}{added the table* environment} +% \changes{v0.97}{2014/05/27}{use adjustwidth in table* environment} +% +% The table* environment provides a table environment for figures across +% text and margin width. +% +% \begin{macrocode} +\DeclareCaptionStyle{widetable}{font=footnotesize} +\RenewDocumentEnvironment{table*}{ O{htbp} } +{ + \begin{table}[#1] + \begin{autoadjustwidth}{}{-\@sidenotes@extrawidth} + \captionsetup{style=widetable} +} +{ + \end{autoadjustwidth} + \end{table} +} +\ExplSyntaxOff +% \end{macrocode} +% \end{environment} +% \Finale +\endinput diff --git a/macros/latex/contrib/sidenotes/sidenotes.ins b/macros/latex/contrib/sidenotes/sidenotes.ins new file mode 100644 index 0000000000..b43f2a68ba --- /dev/null +++ b/macros/latex/contrib/sidenotes/sidenotes.ins @@ -0,0 +1,46 @@ +%% +%% Copyright (C) 2011-2014 by Andy Thomas +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2003/12/01 or later. +%% +%% The author of this work is Andy Thomas +%% + +\input docstrip.tex +\keepsilent + +\usedir{tex/latex/sidenotes} + +\preamble + +IMPORTANT NOTE: + +This is a generated file and you are not allowed to distribute it +without the source of the work. See below about more informations +about the files the work consists of. + +\endpreamble + +\generate{\file{sidenotes.sty}{\from{sidenotes.dtx}{package}}} + +\obeyspaces +\Msg{*************************************************************} +\Msg{* *} +\Msg{* To produce the documentation run the file sidenotes.dtx *} +\Msg{* through LaTeX. *} +\Msg{* *} +\Msg{* To finish the installation you have to move sidenotes.sty *} +\Msg{* into a directory searched by TeX: *} +\Msg{* *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{*************************************************************} + +\endbatchfile diff --git a/macros/latex/contrib/sidenotes/sidenotes.pdf b/macros/latex/contrib/sidenotes/sidenotes.pdf new file mode 100644 index 0000000000..e9cdcbc636 Binary files /dev/null and b/macros/latex/contrib/sidenotes/sidenotes.pdf differ -- cgit v1.2.3