diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2011-08-02 18:37:42 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2011-08-02 18:37:42 +0000 |
commit | ff94e44b3898f59065c492d5e5e597234f1b49b1 (patch) | |
tree | ca2da7b855c1964f46c29a41ed2e2c50be200d9f /Master/texmf-dist/tex/latex/bidi/bidituftesidenote.sty | |
parent | 2880aaf97110f638a133d7ba59e8ecbd15150b2f (diff) |
bidi v1.2.4
git-svn-id: svn://tug.org/texlive/trunk@23326 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/bidi/bidituftesidenote.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/bidi/bidituftesidenote.sty | 485 |
1 files changed, 485 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/bidi/bidituftesidenote.sty b/Master/texmf-dist/tex/latex/bidi/bidituftesidenote.sty new file mode 100644 index 00000000000..821a0aaf8bb --- /dev/null +++ b/Master/texmf-dist/tex/latex/bidi/bidituftesidenote.sty @@ -0,0 +1,485 @@ +%% +%% This is file `bidituftesidenote.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% bidi.dtx (with options: `bidituftesidenote.sty') +%% +%% ______________________________________ +%% Copyright © 2009–2011 Vafa Khalighi +%% +%% License information appended. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bidituftesidenote}[2011/06/17 v0.1 +bidi implementation of tufte sidenote] +\RequirePackage{xifthen} +\RequirePackage{ragged2e} +\RequirePackage{setspace} +\RequirePackage{hopatch} +\def\bidituftesidenotemarginpar{% + \ifhmode + \@bsphack + \@floatpenalty -\@Mii + \else + \@floatpenalty-\@Miii + \fi + \ifinner + \@parmoderr + \@floatpenalty\z@ + \else + \@next\@currbox\@freelist{}{}% + \@next\@marbox\@freelist{\global\count\@marbox\m@ne}% + {\@floatpenalty\z@ + \@fltovf\def\@currbox{\@tempboxa}\def\@marbox{\@tempboxa}}% + \fi + \@ifnextchar [\@bidituftesidenotexmpar\@bidituftesidenoteympar} +\long\def\@bidituftesidenotexmpar[#1]#2{% + \@bidituftesidenotesavemarbox\@marbox{#1}% + \@bidituftesidenotesavemarbox\@currbox{#2}% + \@xympar} +\long\def\@bidituftesidenoteympar#1{% + \@bidituftesidenotesavemarbox\@marbox{#1}% + \global\setbox\@currbox\copy\@marbox + \@xympar} +\long\def \@bidituftesidenotesavemarbox #1#2{% + \global\setbox #1% + \color@vbox + \vtop{% + \hsize\marginparwidth + \@parboxrestore + \@bidituftesidenotemarginparreset + #2% + \@minipagefalse + \outer@nobreak + }% + \color@endbox +} +\def \@bidituftesidenotemarginparreset {% + \reset@font + \normalsize + \@minipagetrue + \everypar{\@minipagefalse\everypar{}\if@RTL@footnote\beginR\else\beginL\fi}% +} +\def\LTRbidituftesidenotemarginpar{% + \ifhmode + \@bsphack + \@floatpenalty -\@Mii + \else + \@floatpenalty-\@Miii + \fi + \ifinner + \@parmoderr + \@floatpenalty\z@ + \else + \@next\@currbox\@freelist{}{}% + \@next\@marbox\@freelist{\global\count\@marbox\m@ne}% + {\@floatpenalty\z@ + \@fltovf\def\@currbox{\@tempboxa}\def\@marbox{\@tempboxa}}% + \fi + \@ifnextchar [\@LTRbidituftesidenotexmpar\@LTRbidituftesidenoteympar} +\long\def\@LTRbidituftesidenotexmpar[#1]#2{% + \@LTRbidituftesidenotesavemarbox\@marbox{#1}% + \@LTRbidituftesidenotesavemarbox\@currbox{#2}% + \@xympar} +\long\def\@LTRbidituftesidenoteympar#1{% + \@LTRbidituftesidenotesavemarbox\@marbox{#1}% + \global\setbox\@currbox\copy\@marbox + \@xympar} +\long\def \@LTRbidituftesidenotesavemarbox #1#2{% + \global\setbox #1% + \color@vbox + \vtop{% + \hsize\marginparwidth + \@parboxrestore + \@LTRbidituftesidenotemarginparreset + #2% + \@minipagefalse + \outer@nobreak + }% + \color@endbox +} +\def \@LTRbidituftesidenotemarginparreset {% + \reset@font + \normalsize + \@minipagetrue + \everypar{\@minipagefalse\everypar{}\beginL}% +} +\def\RTLbidituftesidenotemarginpar{% + \ifhmode + \@bsphack + \@floatpenalty -\@Mii + \else + \@floatpenalty-\@Miii + \fi + \ifinner + \@parmoderr + \@floatpenalty\z@ + \else + \@next\@currbox\@freelist{}{}% + \@next\@marbox\@freelist{\global\count\@marbox\m@ne}% + {\@floatpenalty\z@ + \@fltovf\def\@currbox{\@tempboxa}\def\@marbox{\@tempboxa}}% + \fi + \@ifnextchar [\@RTLbidituftesidenotexmpar\@RTLbidituftesidenoteympar} +\long\def\@RTLbidituftesidenotexmpar[#1]#2{% + \@RTLbidituftesidenotesavemarbox\@marbox{#1}% + \@RTLbidituftesidenotesavemarbox\@currbox{#2}% + \@xympar} +\long\def\@RTLbidituftesidenoteympar#1{% + \@RTLbidituftesidenotesavemarbox\@marbox{#1}% + \global\setbox\@currbox\copy\@marbox + \@xympar} +\long\def \@RTLbidituftesidenotesavemarbox #1#2{% + \global\setbox #1% + \color@vbox + \vtop{% + \hsize\marginparwidth + \@parboxrestore + \@RTLbidituftesidenotemarginparreset + #2% + \@minipagefalse + \outer@nobreak + }% + \color@endbox +} +\def \@RTLbidituftesidenotemarginparreset {% + \reset@font + \normalsize + \@minipagetrue + \everypar{\@minipagefalse\everypar{}\beginR}% +} +\newcommand{\@bidituftesidenote@marginfont}{\normalfont\footnotesize} +\newcommand*{\@bidituftesidenote@sidenote@font}{\@bidituftesidenote@marginfont} +\newcommand*{\@bidituftesidenote@marginnote@font}{\@bidituftesidenote@marginfont} +\newcommand*{\@bidituftesidenote@citation@font}{\@bidituftesidenote@marginfont} +\newcommand*{\setsidenotefont}[1]{\renewcommand*{\@bidituftesidenote@sidenote@font}{#1}} +\newcommand*{\setmarginnotefont}[1]{\renewcommand*{\@bidituftesidenote@marginnote@font}{#1}} +\newcommand*{\setcitationfont}[1]{\renewcommand*{\@bidituftesidenote@citation@font}{#1}} +\newcommand*{\@bidituftesidenote@sidenote@justification}{\@bidituftesidenote@justification@autodetect} +\newcommand*{\@bidituftesidenote@marginnote@justification}{\@bidituftesidenote@justification@autodetect} +\newcommand*{\@bidituftesidenote@citation@justification}{\@bidituftesidenote@justification@autodetect} +\newcommand*{\@bidituftesidenote@justification@autodetect}{\justifying}% +\newcommand{\@bidituftesidenote@margin@par}{% + \setlength{\RaggedRightParindent}{0.5pc}% + \setlength{\JustifyingParindent}{0.5pc}% + \setlength{\parindent}{0.5pc}% + \setlength{\parskip}{0pt}% +} +%% +\@ifundefined{gsetlength}{% +\newcommand*{\gsetlength}[2]{% + \setlength{#1}{#2}% + \global#1=#1\relax% +}% +}{} +%% +\@ifundefined{gsetboolean}{% +\newcommand*{\gsetboolean}[2]{% based on code from ifthen pkg + \lowercase{\def\@tempa{#2}}% + \@ifundefined{@tempswa\@tempa}% + {\PackageError{ifthen}{You can only set a boolean to `true' or `false'}\@ehc}% + {\@ifundefined{#1\@tempa}% + {\PackageError{ifthen}{Boolean #1 undefined}\@ehc}% + {\global\csname#1\@tempa\endcsname}% + }% +}% +}{} +%% +\catcode`\Q=3 +\def\@bidituftesidenote@trim@spaces#1{% + % Use grouping to emulate a multi-token afterassignment queue + \begingroup% + % Put `\toks 0 {' into the afterassignment queue + \aftergroup\toks\aftergroup0\aftergroup{% + % Apply \trimb to the replacement text of #1, adding a leading + % \noexpand to prevent brace stripping and to serve another purpose + % later. + \expandafter\@bidituftesidenote@trim@b\expandafter\noexpand#1Q Q}% + % Transfer the trimmed text back into #1. + \edef#1{\the\toks0}% +} +\def\@bidituftesidenote@trim@b#1 Q{\@bidituftesidenote@trim@c#1Q} +\def\@bidituftesidenote@trim@c#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1} +\catcode`\Q=11 +%% + +\RequirePackage{natbib} +\RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment +\renewcommand\BR@b@bibitem[2][]{% + \ifthenelse{\isempty{#1}}% + {\BR@bibitem{#2}}% + {\BR@bibitem[#1]{#2}}% + \BR@c@bibitem{#2}% +} +\nobibliography* % pre-loads the bibliography keys +%% +\newcounter{@bidituftesidenote@num@bibkeys}% +\newcommand{\@bidituftesidenote@normal@cite}[2][0pt]{% + % Snag the last bibentry in the list for later comparison + \let\@temp@last@bibkey\@empty% + \@for\@temp@bibkey:=#2\do{\let\@temp@last@bibkey\@temp@bibkey}% + \sidenote[][#1]{% + % Loop through all the bibentries, separating them with semicolons and spaces + \normalsize\normalfont\@bidituftesidenote@citation@font% + \setcounter{@bidituftesidenote@num@bibkeys}{0}% + \@for\@temp@bibkeyx:=#2\do{% + \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}% + {\ifthenelse{\equal{\value{@bidituftesidenote@num@bibkeys}}{0}}{}{and\ }% + \@bidituftesidenote@trim@spaces\@temp@bibkeyx% trim spaces around bibkey + \bibentry{\@temp@bibkeyx}}% + {\@bidituftesidenote@trim@spaces\@temp@bibkeyx% trim spaces around bibkey + \bibentry{\@temp@bibkeyx};\ }% + \stepcounter{@bidituftesidenote@num@bibkeys}% + }% + }% +} +%% +\gdef\@bidituftesidenote@citations{}% list of cite keys +\newcommand\@bidituftesidenote@add@citation[1]{\relax% adds a new bibkey to the list of cite keys + \ifx\@bidituftesidenote@citations\@empty\else + \g@addto@macro\@bidituftesidenote@citations{,}% separate by commas + \fi + \g@addto@macro\@bidituftesidenote@citations{#1} +} +\newcommand{\@bidituftesidenote@print@citations}[1][0pt]{% puts the citations in a margin note + % Snag the last bibentry in the list for later comparison + \let\@temp@last@bibkey\@empty% + \@for\@temp@bibkey:=\@bidituftesidenote@citations\do{\let\@temp@last@bibkey\@temp@bibkey}% + \marginpar{% + \hbox{}\vspace*{#1}% + \@bidituftesidenote@citation@font% + \@bidituftesidenote@citation@justification% + \@bidituftesidenote@margin@par% use parindent and parskip settings for marginal text + \vspace*{-1\baselineskip}% + % Loop through all the bibentries, separating them with semicolons and spaces + \setcounter{@bidituftesidenote@num@bibkeys}{0}% + \@for\@temp@bibkeyx:=\@bidituftesidenote@citations\do{% + \ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}% + {\ifthenelse{\equal{\value{@bidituftesidenote@num@bibkeys}}{0}}{}{and\ }% + \@bidituftesidenote@trim@spaces\@temp@bibkeyx% trim spaces around bibkey + \bibentry{\@temp@bibkeyx}}% + {\@bidituftesidenote@trim@spaces\@temp@bibkeyx% trim spaces around bibkey + \bibentry{\@temp@bibkeyx};\ }% + \stepcounter{@bidituftesidenote@num@bibkeys}% + }% + }% +} +%% +\newcommand{\@bidituftesidenote@sidenote@citations}{}% contains list of \cites in sidenote +\newcommand{\@bidituftesidenote@infootnote@cite}[1]{% + \@bidituftesidenote@add@citation{#1} +} +%% +\let\cite\@bidituftesidenote@normal@cite +%% +\RequirePackage{optparams}% for our new sidenote commands -- provides multiple optional arguments for commands +\providecommand{\footnotelayout}{\@bidituftesidenote@sidenote@font\@bidituftesidenote@sidenote@justification} +\renewcommand{\footnotelayout}{\@bidituftesidenote@sidenote@font\@bidituftesidenote@sidenote@justification} +\hopatch@AfterPackage{bidi}{\long\def\@makefntext#1{\@textsuperscript{\@bidituftesidenote@sidenote@font\tiny\@thefnmark}\,\footnotelayout#1}} +\hopatch@AfterPackage{bidi}{\def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}}} +\providecommand*{\multiplefootnotemarker}{3sp} +\providecommand*{\multfootsep}{,} +\hopatch@AfterPackage{bidi}{% +\renewcommand{\@footnotemark}{% + \leavevmode% + \ifhmode% + \edef\@x@sf{\the\spacefactor}% + \@bidituftesidenote@check@multiple@sidenotes% + \nobreak% + \fi% + \@makefnmark% + \ifhmode\spacefactor\@x@sf\fi% + \relax% +}% +} +\newcommand{\@bidituftesidenote@check@multiple@sidenotes}{% + \ifdim\lastkern=\multiplefootnotemarker\relax% + \edef\@x@sf{\the\spacefactor}% + \unkern% + \textsuperscript{\multfootsep}% + \spacefactor\@x@sf\relax% + \fi +} +\hopatch@AfterPackage{bidi}{% +\renewcommand\@footnotetext[2][0pt]{% + \bidituftesidenotemarginpar{% + \hbox{}\vspace*{#1}% + \def\baselinestretch {\setspace@singlespace}% + \reset@font\footnotesize% + \@bidituftesidenote@margin@par% use parindent and parskip settings for marginal text + \vspace*{-1\baselineskip}\noindent% + \protected@edef\@currentlabel{% + \csname p@footnote\endcsname\@thefnmark% + }% + \color@begingroup% + \@makefntext{% + \ignorespaces#2% + }% + \color@endgroup% + }% +}% +\renewcommand\@LTRfootnotetext[2][0pt]{% + \LTRbidituftesidenotemarginpar{% + \hbox{}\vspace*{#1}% + \def\baselinestretch {\setspace@singlespace}% + \reset@font\footnotesize% + \@bidituftesidenote@margin@par% use parindent and parskip settings for marginal text + \vspace*{-1\baselineskip}\noindent% + \protected@edef\@currentlabel{% + \csname p@footnote\endcsname\@thefnmark% + }% + \color@begingroup% + \@makefntext{% + \ignorespaces#2% + }% + \color@endgroup% + }% +}% +\renewcommand\@RTLfootnotetext[2][0pt]{% + \RTLbidituftesidenotemarginpar{% + \hbox{}\vspace*{#1}% + \def\baselinestretch {\setspace@singlespace}% + \reset@font\footnotesize% + \@bidituftesidenote@margin@par% use parindent and parskip settings for marginal text + \vspace*{-1\baselineskip}\noindent% + \protected@edef\@currentlabel{% + \csname p@footnote\endcsname\@thefnmark% + }% + \color@begingroup% + \@makefntext{% + \ignorespaces#2% + }% + \color@endgroup% + }% +}% +} +\newlength{\@bidituftesidenote@sidenote@vertical@offset} +\setlength{\@bidituftesidenote@sidenote@vertical@offset}{0pt} +\long\def\@bidituftesidenote@sidenote[#1][#2]#3{% + \let\cite\@bidituftesidenote@infootnote@cite% use the in-sidenote \cite command + \gdef\@bidituftesidenote@citations{}% clear out any old citations + \ifthenelse{\NOT\isempty{#2}}{% + \gsetlength{\@bidituftesidenote@sidenote@vertical@offset}{#2}% + }{% + \gsetlength{\@bidituftesidenote@sidenote@vertical@offset}{0pt}% + }% + \ifthenelse{\isempty{#1}}{% + % no specific footnote number provided + \stepcounter\@mpfn% + \protected@xdef\@thefnmark{\thempfn}% + \@footnotemark\@footnotetext[\@bidituftesidenote@sidenote@vertical@offset]{#3}% + }{% + % specific footnote number provided + \begingroup% + \csname c@\@mpfn\endcsname #1\relax% + \unrestored@protected@xdef\@thefnmark{\thempfn}% + \endgroup% + \@footnotemark\@footnotetext[\@bidituftesidenote@sidenote@vertical@offset]{#3}% + }% + \@bidituftesidenote@print@citations% print any citations + \let\cite\@bidituftesidenote@normal@cite% go back to using normal in-text \cite command + \unskip\ignorespaces% remove extra white space + \kern-\multiplefootnotemarker% remove \kern left behind by sidenote + \kern\multiplefootnotemarker\relax% add new \kern here to replace the one we yanked +} +\long\def\@LTRbidituftesidenote@sidenote[#1][#2]#3{% + \let\cite\@bidituftesidenote@infootnote@cite% use the in-sidenote \cite command + \gdef\@bidituftesidenote@citations{}% clear out any old citations + \ifthenelse{\NOT\isempty{#2}}{% + \gsetlength{\@bidituftesidenote@sidenote@vertical@offset}{#2}% + }{% + \gsetlength{\@bidituftesidenote@sidenote@vertical@offset}{0pt}% + }% + \ifthenelse{\isempty{#1}}{% + % no specific footnote number provided + \stepcounter\@mpfn% + \protected@xdef\@thefnmark{\thempfn}% + \@footnotemark\@LTRfootnotetext[\@bidituftesidenote@sidenote@vertical@offset]{#3}% + }{% + % specific footnote number provided + \begingroup% + \csname c@\@mpfn\endcsname #1\relax% + \unrestored@protected@xdef\@thefnmark{\thempfn}% + \endgroup% + \@footnotemark\@LTRfootnotetext[\@bidituftesidenote@sidenote@vertical@offset]{#3}% + }% + \@bidituftesidenote@print@citations% print any citations + \let\cite\@bidituftesidenote@normal@cite% go back to using normal in-text \cite command + \unskip\ignorespaces% remove extra white space + \kern-\multiplefootnotemarker% remove \kern left behind by sidenote + \kern\multiplefootnotemarker\relax% add new \kern here to replace the one we yanked +} +\long\def\@RTLbidituftesidenote@sidenote[#1][#2]#3{% + \let\cite\@bidituftesidenote@infootnote@cite% use the in-sidenote \cite command + \gdef\@bidituftesidenote@citations{}% clear out any old citations + \ifthenelse{\NOT\isempty{#2}}{% + \gsetlength{\@bidituftesidenote@sidenote@vertical@offset}{#2}% + }{% + \gsetlength{\@bidituftesidenote@sidenote@vertical@offset}{0pt}% + }% + \ifthenelse{\isempty{#1}}{% + % no specific footnote number provided + \stepcounter\@mpfn% + \protected@xdef\@thefnmark{\thempfn}% + \@footnotemark\@RTLfootnotetext[\@bidituftesidenote@sidenote@vertical@offset]{#3}% + }{% + % specific footnote number provided + \begingroup% + \csname c@\@mpfn\endcsname #1\relax% + \unrestored@protected@xdef\@thefnmark{\thempfn}% + \endgroup% + \@footnotemark\@RTLfootnotetext[\@bidituftesidenote@sidenote@vertical@offset]{#3}% + }% + \@bidituftesidenote@print@citations% print any citations + \let\cite\@bidituftesidenote@normal@cite% go back to using normal in-text \cite command + \unskip\ignorespaces% remove extra white space + \kern-\multiplefootnotemarker% remove \kern left behind by sidenote + \kern\multiplefootnotemarker\relax% add new \kern here to replace the one we yanked +} +\newcommand{\sidenote}{\optparams{\@bidituftesidenote@sidenote}{[][0pt]}} +\newcommand{\LTRsidenote}{\optparams{\@LTRbidituftesidenote@sidenote}{[][0pt]}} +\newcommand{\RTLsidenote}{\optparams{\@RTLbidituftesidenote@sidenote}{[][0pt]}} +\hopatch@AfterPackage{bidi}{% +\renewcommand{\footnote}{\optparams{\@bidituftesidenote@sidenote}{[][0pt]}}% +\renewcommand{\LTRfootnote}{\optparams{\@LTRbidituftesidenote@sidenote}{[][0pt]}}% +\renewcommand{\RTLfootnote}{\optparams{\@RTLbidituftesidenote@sidenote}{[][0pt]}}% +} +%% +\newcommand\marginnote[2][0pt]{% + \let\cite\@bidituftesidenote@infootnote@cite% use the in-sidenote \cite command + \gdef\@bidituftesidenote@citations{}% clear out any old citations + \bidituftesidenotemarginpar{\hbox{}\vspace*{#1}\@bidituftesidenote@marginnote@font\@bidituftesidenote@marginnote@justification\@bidituftesidenote@margin@par\vspace*{-1\baselineskip}\noindent #2}% + \@bidituftesidenote@print@citations% print any citations + \let\cite\@bidituftesidenote@normal@cite% go back to using normal in-text \cite command +} +\newcommand\LTRmarginnote[2][0pt]{% + \let\cite\@bidituftesidenote@infootnote@cite% use the in-sidenote \cite command + \gdef\@bidituftesidenote@citations{}% clear out any old citations + \LTRbidituftesidenotemarginpar{\hbox{}\vspace*{#1}\@bidituftesidenote@marginnote@font\@bidituftesidenote@marginnote@justification\@bidituftesidenote@margin@par\vspace*{-1\baselineskip}\noindent #2}% + \@bidituftesidenote@print@citations% print any citations + \let\cite\@bidituftesidenote@normal@cite% go back to using normal in-text \cite command +} +\newcommand\RTLmarginnote[2][0pt]{% + \let\cite\@bidituftesidenote@infootnote@cite% use the in-sidenote \cite command + \gdef\@bidituftesidenote@citations{}% clear out any old citations + \RTLbidituftesidenotemarginpar{\hbox{}\vspace*{#1}\@bidituftesidenote@marginnote@font\@bidituftesidenote@marginnote@justification\@bidituftesidenote@margin@par\vspace*{-1\baselineskip}\noindent #2}% + \@bidituftesidenote@print@citations% print any citations + \let\cite\@bidituftesidenote@normal@cite% go back to using normal in-text \cite command +} +%% +%% Copyright © 2009–2011 Vafa Khalighi <vafa018@gmail.com> +%% +%% It may be distributed and/or modified under the LaTeX Project Public License, +%% version 1.3c or higher (your choice). The latest version of +%% this license is at: http://www.latex-project.org/lppl.txt +%% +%% This work is “author-maintained” (as per LPPL maintenance status) +%% by Vafa Khalighi. +%% +%% +%% +%% +%% End of file `bidituftesidenote.sty'. |