diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/sidenotes/sidenotes.sty | 242 |
1 files changed, 148 insertions, 94 deletions
diff --git a/Master/texmf-dist/tex/latex/sidenotes/sidenotes.sty b/Master/texmf-dist/tex/latex/sidenotes/sidenotes.sty index 47596038a85..36d41bc7b31 100644 --- a/Master/texmf-dist/tex/latex/sidenotes/sidenotes.sty +++ b/Master/texmf-dist/tex/latex/sidenotes/sidenotes.sty @@ -12,117 +12,171 @@ %% without the source of the work. See below about more informations %% about the files the work consists of. %% -\ProvidesPackage{sidenotes}[% - 2014/02/14 v0.96a rich text in the margin for LaTeX] +\RequirePackage{l3keys2e}% +\ProvidesExplPackage{sidenotes}{2014/06/05}{0.97e}{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 +\ExplSyntaxOn +\keys_define:nn { sidenotes } + { + oneside .bool_set:N = \sidenotes_oneside + } +\ProcessKeysOptions { sidenotes } \newcounter{sidenote} % make a counter \setcounter{sidenote}{1} % init the counter -\ExplSyntaxOn -\DeclareExpandableDocumentCommand{\IfNoValueOrEmptyTF}{mmm} +\DeclareExpandableDocumentCommand{\IfNoValueOrEmptyTF}{ m m m } { \IfNoValueTF{#1} - {#2} % true - {\tl_if_empty:nTF {#1} {#2} {#3}} % false + {#2} + {\tl_if_empty:nTF {#1} {#2} {#3}} +} +\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{,}} + {} +} +\NewDocumentCommand \@sidenotes@placemarginal { m m } +{ + \IfNoValueOrEmptyTF{#1} + {\marginpar{#2}} + {\marginnote{#2}[#1]} +} +\NewDocumentCommand \sidenote { o o +m } +{ + \sidenotemark[#1] + \sidenotetext[#1][#2]{#3} + \@sidenotes@multimarker +} +\NewDocumentCommand \sidenotemark { o } +{ + \@sidenotes@multichecker + \IfNoValueOrEmptyTF{#1} + {\@sidenotes@thesidenotemark{\thesidenote}} + {\@sidenotes@thesidenotemark{#1}} + \@sidenotes@multimarker +} +\NewDocumentCommand \sidenotetext { o o +m } +{ + \IfNoValueOrEmptyTF{#1} + { + \@sidenotes@placemarginal{#2}{\textsuperscript{\thesidenote}{}~#3} + \refstepcounter{sidenote} +} + {\@sidenotes@placemarginal{#2}{\textsuperscript{#1}~#3}} } -\ExplSyntaxOff -\def\@sidenotes@ifnextchar#1#2#3{% -\let\@sidenotes@buffere #1\def\@sidenotes@buffera{#2}% -\def\@sidenotes@bufferb{#3}\futurelet\@sidenotes@bufferc\@sidenotes@ifnextchar@real}% -\def\@sidenotes@ifnextchar@real{% -\ifx\@sidenotes@bufferc \@sidenotes@buffere \let\@sidenotes@bufferd\@sidenotes@buffera% -\else\let\@sidenotes@bufferd\@sidenotes@bufferb\fi\@sidenotes@bufferd}% -\NewDocumentCommand \sidenote { o o +m } {% -\sidenotemark[#1]% -\sidenotetext[#1][#2]{#3}% -\@sidenotes@ifnextchar\sidenote{\kern-0.07em\textsuperscript{,}}% -{\@sidenotes@ifnextchar\sidecite{\kern-0.07em\textsuperscript{,}}{}}% -} -\NewDocumentCommand \sidenotemark { o } {% -\nobreak\hspace{0.1pt}\nobreak% -\IfNoValueOrEmptyTF{#1}% -{% -\textsuperscript{\thesidenote}% -}% if no argument is given use sidenote counter% -{\textsuperscript{#1}}% print out the argument otherwise -\@sidenotes@ifnextchar\sidenote{\textsuperscript{,}}{}% -\ignorespaces% -}% -\NewDocumentCommand \sidenotetext { o o +m } {% -\IfNoValueOrEmptyTF{#1}{% sitenotemark given? -\IfNoValueOrEmptyTF{#2}% offset given? -{\marginpar{\textsuperscript{\thesidenote}{} #3}}% -{\marginnote{\textsuperscript{\thesidenote}{} #3}[#2]}% -\refstepcounter{sidenote}}% -{\IfNoValueOrEmptyTF{#2}% offset given? -{\marginpar{\textsuperscript{#1} #3}}% -{\marginnote{\textsuperscript{#1} #3}[#2]}}% -}% \DeclareCaptionStyle{sidecaption}{font=footnotesize} -\NewDocumentCommand \sidecaption {s o o m} {% -\captionsetup{style=sidecaption}% -\IfBooleanTF{#1}%is the macro starred -{\IfNoValueOrEmptyTF{#2}% -{\marginnote{\caption*{#4}}}% -{\marginnote{\caption*{#4}}[#2]}% -}% yes, starred macro -{% -\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]}% -}% no, unstarred macro -} -\newsavebox{\@sidenotes@sidefigurebox} +\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]} + } +} +\newsavebox{\@sidenotes@marginfigurebox} \DeclareCaptionStyle{marginfigure}{font=footnotesize} -\NewDocumentEnvironment{marginfigure}{o} -{\begin{lrbox}{\@sidenotes@sidefigurebox}% -\begin{minipage}{\marginparwidth}% -\captionsetup{type=figure,style=marginfigure}}% -{\end{minipage}% -\end{lrbox}% -\IfNoValueOrEmptyTF{#1}% offset? -{\marginpar{\usebox{\@sidenotes@sidefigurebox}}}% no offset -{\marginnote{\usebox{\@sidenotes@sidefigurebox}}[#1]}% offset +\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}} } \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}% -\IfNoValueOrEmptyTF{#1}% offset? -{\marginpar{\usebox{\@sidenotes@margintablebox}}} % -{\marginnote{\usebox{\@sidenotes@margintablebox}}[#1]}% -}% +\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}} +} \AtBeginDocument{% \newlength{\@sidenotes@extrawidth} \setlength{\@sidenotes@extrawidth}{\marginparwidth} -\addtolength{\@sidenotes@extrawidth}{\marginparsep} -} -\DeclareCaptionStyle{widefigure}{margin={0pt,-\@sidenotes@extrawidth},font=footnotesize} -\newcommand{\@sidenotes@adjust}{% - \checkoddpage% - \ifoddpage% - \else% -\hspace{-\@sidenotes@extrawidth}% - \fi} -\renewenvironment{figure*}[1][htbp]{\begin{figure}[#1]% - \@sidenotes@adjust% - \captionsetup{style=widefigure}% -}{\end{figure}}% - -\DeclareCaptionStyle{widetable}{margin={0pt,-\@sidenotes@extrawidth},font=footnotesize} -\renewenvironment{table*}[1][htbp]{\begin{table}[#1]% - \@sidenotes@adjust% - \captionsetup{style=widetable}% -}{\end{table}}% +\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} +} +\DeclareCaptionStyle{widetable}{font=footnotesize} +\RenewDocumentEnvironment{table*}{ O{htbp} } +{ + \begin{table}[#1] + \begin{autoadjustwidth}{}{-\@sidenotes@extrawidth} + \captionsetup{style=widetable} +} +{ + \end{autoadjustwidth} + \end{table} +} +\ExplSyntaxOff \endinput %% %% End of file `sidenotes.sty'. |