summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/snotez
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-12-15 22:21:35 +0000
committerKarl Berry <karl@freefriends.org>2020-12-15 22:21:35 +0000
commit31df9fd674e93a1c37a88762ce9eb25a31468db4 (patch)
treecc32a02bcb79c678f3c6db693dedfebca6c7d765 /Master/texmf-dist/tex/latex/snotez
parent595a4e906e4a0ebe6b92b8747479bc4c0bfc6dd7 (diff)
snotez (14dec20)
git-svn-id: svn://tug.org/texlive/trunk@57147 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/snotez')
-rw-r--r--Master/texmf-dist/tex/latex/snotez/snotez.sty297
1 files changed, 169 insertions, 128 deletions
diff --git a/Master/texmf-dist/tex/latex/snotez/snotez.sty b/Master/texmf-dist/tex/latex/snotez/snotez.sty
index 62c0c2d53a6..0891f93dfe5 100644
--- a/Master/texmf-dist/tex/latex/snotez/snotez.sty
+++ b/Master/texmf-dist/tex/latex/snotez/snotez.sty
@@ -8,28 +8,22 @@
% Web: https://bitbucket.org/cgnieder/enotez/
% E-Mail: contact@mychemistry.eu
% --------------------------------------------------------------------------
-% Copyright 2012--2013 Clemens Niederberger
+% Copyright 2012--2020 Clemens Niederberger
%
% This work may be distributed and/or modified under the
-% conditions of the LaTeX Project Public License, either version 1.3
+% conditions of the LaTeX Project Public License, either version 1.3c
% 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 2005/12/01 or later.
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2008/05/04 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-% The snotez package consists of the files
-% - snotez.sty, snotez_en.tex, snotez_en.pdf, README
-% --------------------------------------------------------------------------
-% If you have any ideas, questions, suggestions or bugs to report, please
-% feel free to contact me.
-% --------------------------------------------------------------------------
-\def\snotez@date{2013/04/21}
-\def\snotez@version{v0.3}
+\def\snotez@date{2020/12/14}
+\def\snotez@version{v0.5a}
\def\snotez@description{sidenote support for LaTeX 2e (CN)}
\NeedsTeXFormat{LaTeX2e}
@@ -41,49 +35,45 @@
{\AtEndPreamble{\RequirePackage{perpage}}}
% --------------------------------------------------------------------------
-% message handling
-\def\snotez@create@message#1{%
- \ifstrequal{#1}{Error}
- {%
- \lowercase{\csdef{snotez@#1}}##1##2{%
- \csuse{Package#1}{snotez}{##1}{##2}}%
- }{%
- \lowercase{\csdef{snotez@#1}}##1{%
- \csuse{Package#1}{snotez}{##1}}%
- }}
-\snotez@create@message{Error}
-\snotez@create@message{Warning}
-\snotez@create@message{WarningNoLine}
-\snotez@create@message{Info}
-
-% --------------------------------------------------------------------------
% package options:
\newbool{snotez@marginnote}
\newbool{snotez@perpage}
\newbool{snotez@footnote}
\newbool{snotez@dblarg}
-\booltrue{snotez@dblarg}
-\def\snotez@note@mark@sep{\space}
-\def\snotez@note@mark@format#1{\@textsuperscript{\normalfont#1}}
-\def\snotez@format{\footnotesize}
-\def\snotez@text@mark@format#1{\@textsuperscript{\normalfont#1}}
+\newcommand*\snotez@note@mark@sep{\space}
+\newcommand*\snotez@note@mark@format[1]{\@textsuperscript{\normalfont#1}}
+\newcommand*\snotez@format{\normalfont\footnotesize}
+\newcommand*\snotez@text@mark@format[1]{\@textsuperscript{\normalfont#1}}
\pgfkeys{
snotez/.cd,
% all sidenotes use \marginnote:
marginnote/.is if = snotez@marginnote ,
- text-format/.code = \def\snotez@format{#1} ,
+ % formatting of the note text:
+ text-format/.code = \renewcommand*\snotez@format{#1} ,
text-format+/.code =
- \expandafter\def\expandafter\snotez@format\expandafter{\snotez@format#1} ,
+ \expandafter\renewcommand
+ \expandafter*%
+ \expandafter\snotez@format
+ \expandafter{\snotez@format#1} ,
% make sidenotes counted per page:
perpage/.is if = snotez@perpage ,
- note-mark-sep/.code = \def\snotez@note@mark@sep{#1} ,
- note-mark-format/.code = \def\snotez@note@mark@format##1{#1} ,
- text-mark-format/.code = \def\snotez@text@mark@format##1{#1} ,
+ % formatting of the note mark:
+ note-mark-sep/.code = \renewcommand*\snotez@note@mark@sep{#1} ,
+ note-mark-format/.code = \renewcommand*\snotez@note@mark@format[1]{#1} ,
+ text-mark-format/.code = \renewcommand*\snotez@text@mark@format[1]{#1} ,
% make all footnotes sidenotes:
footnote/.is if = snotez@footnote ,
- dblarg/.is if = snotez@dblarg
+ % change optional argument input:
+ dblarg/.is if = snotez@dblarg ,
+ % formmatting of the sidefloats' contents:
+ sidefloat-format/.code = \renewcommand*\snotez@sidefloat@format{#1} ,
+ sidefloat-format+/.code =
+ \expandafter\renewcommand
+ \expandafter*%
+ \expandafter\snotez@sidefloat@format
+ \expandafter{\snotez@sidefloat@format#1}
}
\ProcessPgfOptions*
@@ -93,54 +83,62 @@
% --------------------------------------------------------------------------
% the \sidenote command
\ifbool{snotez@dblarg}{
- % syntax:
- % - \sidenote{text}
- % - \sidenote[mark]{text}
- % - \sidenote[offset][mark]{text}
\newrobustcmd*\sidenote{%
- \@ifnextchar[%
- {\snotez@sidenote@aux@i}
- {\snotez@sidenote@aux@ii{}[]}% no option
- }
-
- \def\snotez@sidenote@aux@i[#1]{%
- \@ifnextchar[%
- {\snotez@sidenote@aux@ii{#1}}% two options
- {\snotez@sidenote@aux@ii{}[{#1}]}% one option
+ \snotez@sidenote@dblarg
}
}{
- % syntax:
- % - \sidenote{text}
- % - \sidenote[mark]{text}
- % - \sidenote(offset){text}
- % - \sidenote(offset)[mark]{text}
\newrobustcmd*\sidenote{%
- \@ifnextchar(%
- {\snotez@sidenote@aux@i}% offset
- {%
- \@ifnextchar[
- {\snotez@sidenote@aux@ii{}}% no offset nut mark
- {\snotez@sidenote@aux@ii{}[]}% no offset and no mark
- }%
+ \snotez@sidenote@nodblarg
}
+}
- \def\snotez@sidenote@aux@i(#1){%
- \@ifnextchar[%
- {\snotez@sidenote@aux@ii{#1}}% mark
- {\snotez@sidenote@aux@ii{#1}[]}% no mark
- }
+% syntax:
+% - \sidenote{text}
+% - \sidenote[mark]{text}
+% - \sidenote[offset][mark]{text}
+\newrobustcmd*\snotez@sidenote@dblarg{%
+ \@ifnextchar[%
+ {\snotez@sidenote@dblarg@aux}
+ {\snotez@sidenote@aux{}[]}% no option
+}
+
+\protected\def\snotez@sidenote@dblarg@aux[#1]{%
+ \@ifnextchar[%
+ {\snotez@sidenote@aux{#1}}% two options
+ {\snotez@sidenote@aux{}[{#1}]}% one option
+}
+
+% syntax:
+% - \sidenote{text}
+% - \sidenote[mark]{text}
+% - \sidenote(offset){text}
+% - \sidenote(offset)[mark]{text}
+\newrobustcmd*\snotez@sidenote@nodblarg{%
+ \@ifnextchar(%
+ {\snotez@sidenote@nodblarg@aux}% offset
+ {%
+ \@ifnextchar[
+ {\snotez@sidenote@aux{}}% no offset but mark
+ {\snotez@sidenote@aux{}[]}% no offset and no mark
+ }%
+}
+
+\protected\def\snotez@sidenote@nodblarg@aux(#1){%
+ \@ifnextchar[%
+ {\snotez@sidenote@aux{#1}}% mark
+ {\snotez@sidenote@aux{#1}[]}% no mark
}
% #1: offset
% #2: mark
% #3: text
-\long\def\snotez@sidenote@aux@ii#1[#2]#3{%
+\long\def\snotez@sidenote@aux#1[#2]#3{%
\snotez@mark{#2}%
\snotez@text{#1}{#3}%
}
% this one is very much \@footnotemark from latex.ltx:
-\def\snotez@write@mark#1{%
+\newrobustcmd*\snotez@write@mark[1]{%
\leavevmode
\ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
#1%
@@ -148,17 +146,23 @@
\relax
}
-\def\snotez@mark#1{%
+\newrobustcmd*\snotez@mark[1]{%
\ifblank{#1}% or \ifstrempty?
- {\refstepcounter{sidenote}\protected@xdef\@the@snotez@mark{\thesidenote}}
- {\protected@edef\@currentlabel{#1}\protected@xdef\@the@snotez@mark{#1}}%
- \snotez@write@mark{\hbox{\snotez@text@mark@format{\@the@snotez@mark}}}%
+ {%
+ \refstepcounter{sidenote}%
+ \protected@xdef\@the@snotez@mark{\thesidenote}%
+ }
+ {%
+ \protected@edef\@currentlabel{#1}%
+ \protected@xdef\@the@snotez@mark{#1}%
+ }%
+ \snotez@write@mark{%
+ \hbox{\snotez@text@mark@format{\@the@snotez@mark}}}%
}
-\ifcsdef{c@chapter}
+\ifltxcounter{chapter}
{\newcounter{sidenote}[chapter]}
- {\newcounter{sidenote}%
-}
+ {\newcounter{sidenote}}
% --------------------------------------------------------------------------
% the \sidenotemark command
@@ -167,55 +171,63 @@
% --------------------------------------------------------------------------
% the \sidenotetext command
\ifbool{snotez@dblarg}{
- % syntax:
- % - \sidenotetext{text}
- % - \sidenotetext[mark]{text}
- % - \sidenotetext[offset][mark]{text}
\newrobustcmd*\sidenotetext{%
- \@ifnextchar[%
- {\snotez@sidenotetext@aux@i}
- {\snotez@sidenotetext@aux@ii{}[]}% no option
- }
-
- \def\snotez@sidenotetext@aux@i[#1]{%
- \@ifnextchar[%
- {\snotez@sidenotetext@aux@ii{#1}}% two options
- {\snotez@sidenotetext@aux@ii{}[{#1}]}% one option
+ \snotez@sidenotetext@dblarg
}
}{
- % syntax:
- % - \sidenotetext{text}
- % - \sidenotetext[mark]{text}
- % - \sidenotetext(offset){text}
- % - \sidenotetext(offset)[mark]{text}
\newrobustcmd*\sidenotetext{%
- \@ifnextchar(%
- {\snotez@sidenotetext@aux@i}% offset
- {%
- \@ifnextchar[
- {\snotez@sidenotetext@aux@ii{}}% no offset nut mark
- {\snotez@sidenotetext@aux@ii{}[]}% no offset and no mark
- }%
+ \snotez@sidenotetext@nodblarg
}
+}
- \def\snotez@sidenotetext@aux@i(#1){%
- \@ifnextchar[%
- {\snotez@sidenotetext@aux@ii{#1}}% mark
- {\snotez@sidenotetext@aux@ii{#1}[]}% no mark
- }
+% syntax:
+% - \sidenotetext{text}
+% - \sidenotetext[mark]{text}
+% - \sidenotetext[offset][mark]{text}
+\newrobustcmd*\snotez@sidenotetext@dblarg{%
+ \@ifnextchar[%
+ {\snotez@sidenotetext@dblarg@aux}
+ {\snotez@sidenotetext@aux{}[]}% no option
+}
+
+\protected\def\snotez@sidenotetext@dblarg@aux[#1]{%
+ \@ifnextchar[%
+ {\snotez@sidenotetext@aux{#1}}% two options
+ {\snotez@sidenotetext@aux{}[{#1}]}% one option
+}
+
+% syntax:
+% - \sidenotetext{text}
+% - \sidenotetext[mark]{text}
+% - \sidenotetext(offset){text}
+% - \sidenotetext(offset)[mark]{text}
+\newrobustcmd*\snotez@sidenotetext@nodblarg{%
+ \@ifnextchar(%
+ {\snotez@sidenotetext@nodblarg@aux}% offset
+ {%
+ \@ifnextchar[
+ {\snotez@sidenotetext@aux{}}% no offset nut mark
+ {\snotez@sidenotetext@aux{}[]}% no offset and no mark
+ }%
+}
+
+\protected\def\snotez@sidenotetext@nodblarg@aux(#1){%
+ \@ifnextchar[%
+ {\snotez@sidenotetext@aux{#1}}% mark
+ {\snotez@sidenotetext@aux{#1}[]}% no mark
}
% #1: offset
% #2: mark
% #3: text
-\long\def\snotez@sidenotetext@aux@ii#1[#2]#3{%
+\long\protected\def\snotez@sidenotetext@aux#1[#2]#3{%
\ifblank{#2}{}{\protected@xdef\@the@snotez@mark{#2}}%
\snotez@text{#1}{#3}%
}
% #1: offset
% #2: text
-\def\snotez@text#1#2{%
+\newrobustcmd*\snotez@text[2]{%
\ifblank{#1}
{%
\snotez@marginpar{%
@@ -228,22 +240,54 @@
\snotez@format
\snotez@write@mark{\snotez@note@mark@format{\@the@snotez@mark}}%
\snotez@note@mark@sep#2%
- }[\snotez@if@nblskip{#1}{\@cdr#1\@nil\baselineskip}{#1}]%
+ }[\snotez@if@nblskip{#1}]%
}%
}
-\def\snotez@if@nblskip#1{%
+\newcommand*\snotez@if@nblskip[1]{%
+ % if #1 starts with * gobble it and add \baselineskip:
\expandafter\ifx\@car#1\@nil*%
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
+ {\@cdr#1\@nil\baselineskip}%
+ {#1}%
}
\let\snotez@marginpar\marginpar
\let\snotez@marginnote\marginnote
% --------------------------------------------------------------------------
+% margin floats with captions, based on an idea in tufte-latex
+\newsavebox\snotez@sidefloat@box
+\newcommand*\snotez@sidefloat@format{\raggedright}
+
+\newenvironment{snotez@sidefloat}[2]
+ {%
+ \def\@captype{#1}%
+ \begin{lrbox}{\snotez@sidefloat@box}%
+ \minipage{\marginparwidth}%
+ \snotez@sidefloat@format#2%
+ }
+ {
+ \endminipage
+ \end{lrbox}%
+ \marginpar{\unhbox\snotez@sidefloat@box}%
+ }
+
+\newrobustcmd*\snotez@new@sidefloat[2]{%
+ \newenvironment{side#1}
+ {\snotez@sidefloat{#1}{#2}}
+ {\endsnotez@sidefloat}%
+}
+
+\newrobustcmd*\newsnotezfloat[2][]{\snotez@new@sidefloat{#2}{#1}}
+
+\newsnotezfloat{figure}
+\newsnotezfloat{table}
+
+% --------------------------------------------------------------------------
% process preamble options:
\AtBeginDocument{
% if option `footnote=true' let \footnote to \sidenote:
@@ -252,13 +296,17 @@
\let\footnote\sidenote
\let\footnotemark\sidenotemark
\let\footnotetext\sidenotetext
+ \ifdef\multfootnote{%
+ \let\multfootnote\multsidenote
+ }{}%
}{}
% if option `marginnote=true' use \marginnote for all notes:
\ifbool{snotez@marginnote}
{%
\let\snotez@marginpar\marginnote
- \snotez@info{All sidenotes are now using \string\marginnote^^J
- instead of \string\marginpar}%
+ \PackageInfo{snotez}
+ {All sidenotes are now using \string\marginnote^^J
+ instead of \string\marginpar}%
}%
{}
}
@@ -268,19 +316,6 @@
\ifbool{snotez@perpage}
{\MakeSortedPerPage{sidenote}}
{\MakeSorted{sidenote}}%
- \@ifpackageloaded{fnpct}
- {%
- \ifbool{snotez@dblarg}
- {}
- {%
- \snotez@error
- {When you're using the `fnpct' package together with^^J
- `snotez' you need to enable the `dblarg' option!}
- {When you're using the `fnpct' package together with^^J
- `snotez' you need to enable the `dblarg' option!}%
- }%
- }
- {}%
}
\endinput
@@ -296,4 +331,10 @@
- allow `*' syntax for offsets that are multiples of
\baselineskip
- syntax change in optional arguments; option `dblarg'
- provides previous syntax
+ provides previous syntax >> this is the default
+2013/06/13 v0.3a - better separation of definition of \sidenote and
+ \sidenotetext commands and the internal commands
+2013/11/21 v0.4 - robustify commands where appropriate
+ - use cnltx-base
+2020/01/12 v0.5 - remove dependency on `cnltx-base'
+2020/12/14 v0.5a - fix issue #1