summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-01-16 23:10:04 +0000
committerKarl Berry <karl@freefriends.org>2017-01-16 23:10:04 +0000
commitbbdcfbc2b8f537da6c148a5e3cfc669664657baa (patch)
treeb04062a030a6ed4ad8455a0aab8e5d3e68b8d074 /Master/texmf-dist/source/xelatex/bidi/bidi.dtx
parentf937c24995524ae21094db586f6469ea1b034c93 (diff)
bidi (16jan17)
git-svn-id: svn://tug.org/texlive/trunk@42967 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/xelatex/bidi/bidi.dtx')
-rw-r--r--Master/texmf-dist/source/xelatex/bidi/bidi.dtx182
1 files changed, 106 insertions, 76 deletions
diff --git a/Master/texmf-dist/source/xelatex/bidi/bidi.dtx b/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
index 6e9d3d9bfa0..712f71a0098 100644
--- a/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
+++ b/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
@@ -5,7 +5,7 @@
%<*readme>
___________________
The bidi package
-v20.6
+v20.7
This package provides a convenient interface for typesetting
bidirectional texts in Plain TeX and LaTeX, using XeTeX engine.
@@ -25,13 +25,13 @@ a minimal working example showing the issue, and always choose the appropriate
label for your query (i.e. if you are reporting any bugs, choose `Bug' label).
-Current version release date: 2016/11/30
+Current version release date: 2017/01/16
___________________
Vafa Khalighi
persian-tex@tug.org
-Copyright (c) 2007--2016
+Copyright (c) 2007--2017
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
@@ -49,7 +49,7 @@ by Vafa Khalighi.
\preamble
__________________________________________________
- Copyright (c) 2009--2016 Vafa Khalighi <persian-tex@tug.org>
+ Copyright (c) 2009--2017 Vafa Khalighi <persian-tex@tug.org>
It may be distributed and/or modified under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
@@ -321,7 +321,7 @@ by Vafa Khalighi.
%\changes{v13.9}{2013/09/23}{Added implementaion of the package.}
% \title{\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}\\
%\LARGE Bidirectional typesetting in plain \TeX{} and \LaTeX, using \XeTeX{} engine\\[5pt]
-%\large Documentation for \textcolor{blue!65!black}{version 20.6}}
+%\large Documentation for \textcolor{blue!65!black}{version 20.7}}
% \author{Vafa Khalighi\\
% \url{persian-tex@tug.org}}
%\setcounter{page}{0}
@@ -332,7 +332,7 @@ by Vafa Khalighi.
%\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}
%
%\Large
-%Documentation for \textcolor{blue!65!black}{version 20.6}}
+%Documentation for \textcolor{blue!65!black}{version 20.7}}
%
%\vskip 0pt plus 3fill
%\textit{\large to my Master, \textbf{Ferdowsi The Great}}
@@ -356,7 +356,7 @@ by Vafa Khalighi.
%
%\vskip 0pt plus 3fill
%
-%Copyright (c) 2007--2016 Vafa Khalighi
+%Copyright (c) 2007--2017 Vafa Khalighi
%
%\medskip
%Permission is granted to distribute and/or modify \emph{both the documentation and the code} under the conditions of the \LaTeX{} Project Public License, either version 1.3c of this license or (at your option) any later version.
@@ -381,9 +381,9 @@ by Vafa Khalighi.
%* and LaTeX. The package includes adaptations
%* for use with many other commonly-used packages.
%*
-%* Copyright (c) 2009--2016 Vafa Khalighi
+%* Copyright (c) 2009--2017 Vafa Khalighi
%*
-%* 2016/11/30, v20.6
+%* 2017/01/16, v20.7
%*
%* License: LaTeX Project Public License, version
%* 1.3c or higher (your choice)
@@ -855,7 +855,6 @@ by Vafa Khalighi.
%\begin{BDef}
%\Lcs{LTRsidenote}\quad\Lcs{RTLsidenote}\quad\Lcs{LTRmarginnote}\quad\Lcs{RTLmarginnote}
%\end{BDef}
-%\item \textsf{biditufte-book} and \textsf{biditufte-handout} classes provide two extra options; \textsf{RTLgeometry} (active when loading either of classes) and \textsf{LTRgeometry}.
%\item \textsf{biditufte} bundle unlike \textsf{tufts-latex} package, only provides justified lines.
%\item Some features of \textsf{tufte-latex} that does not make any sense in RTL, do not exist in \textsf{biditufte} bundle (no need for \textsf{soul}, \textsf{letterspace} and \textsf{macrotype} packages).
%\item If you want to configure \textsf{biditufte-book} class for your own needs, then you can create a file with the name \texttt{biditufte-book.cfg} and put your \LaTeX{} macros in that file; similarly, if you want to configure \textsf{biditufte-handout} class for your own needs, then you can create a file with the name \texttt{biditufte-handout.cfg} and put your \LaTeX{} macros in that file.
@@ -1138,7 +1137,7 @@ by Vafa Khalighi.
%\iffalse
%<*table>
%\fi
-%% \CheckSum{47593}
+%% \CheckSum{47651}
%% \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
@@ -2981,8 +2980,8 @@ by Vafa Khalighi.
% \subsection{\textsf{bidi.sty}}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\def\bididate{2016/11/30}
-\def\bidiversion{v20.6}
+\def\bididate{2017/01/16}
+\def\bidiversion{v20.7}
\ProvidesPackage{bidi}[\bididate\space \bidiversion\space
Bidirectional typesetting in plain TeX and LaTeX]
\edef\@bidi@info{****************************************************^^J%
@@ -2995,7 +2994,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
* and LaTeX. The package includes adaptations^^J%
* for use with many other commonly-used packages.^^J%
* ^^J%
-* Copyright (c) 2009--2016 Vafa Khalighi^^J%
+* Copyright (c) 2009--2017 Vafa Khalighi^^J%
* ^^J%
* \bididate, \bidiversion^^J%
* ^^J%
@@ -3011,6 +3010,25 @@ Bidirectional typesetting in plain TeX and LaTeX]
\typeout{\@bidi@info}
\edef\bidi@everyjob{\the\everyjob}
\everyjob{\bidi@everyjob\typeout{\@bidi@info}}
+\edef\@bidi@strip@v@bidiversion{\expandafter\@gobble\bidiversion}
+\newcommand*{\IfbidiPackageVersionLater}[1]{%
+ \ifdim\@bidi@strip@v@bidiversion pt > #1 pt %
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+\newcommand*{\IfbidiPackageVersionBefore}[1]{%
+ \ifdim\@bidi@strip@v@bidiversion pt < #1 pt %
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+\newcommand*{\IfbidiPackageVersion}[1]{%
+ \ifdim\@bidi@strip@v@bidiversion pt = #1 pt %
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
\RequirePackage{iftex}
\RequireXeTeX
\RequirePackage{biditools}
@@ -3977,14 +3995,30 @@ ill-advised in the old versions of bidi package.%
{\@ifundefined{#1\@tempa}%
{\PackageError{biditools}{Boolean #1 undefined}\@ehc}%
{\csname#1\@tempa\endcsname}}}
+\newcommand*{\GlobalSetBoolean}[2]{%
+ \lowercase{\def\@tempa{#2}}%
+ \@ifundefined{@tempswa\@tempa}%
+ {\PackageError{biditools}%
+ {You can only set a boolean to `true' or `false'}\@ehc}%
+ {\@ifundefined{#1\@tempa}%
+ {\PackageError{biditools}{Boolean #1 undefined}\@ehc}%
+ {\global\csname#1\@tempa\endcsname}}}
\newcommand*{\SetatBoolean}[2]{%
\lowercase{\def\@tempa{#2}}%
\@ifundefined{@tempswa\@tempa}%
{\PackageError{biditools}%
{You can only set a boolean to `true' or `false'}\@ehc}%
{\@ifundefined{@#1\@tempa}%
- {\PackageError{ifthen}{Boolean @#1 undefined}\@ehc}%
+ {\PackageError{biditools}{Boolean @#1 undefined}\@ehc}%
{\csname @#1\@tempa\endcsname}}}
+\newcommand*{\GlobalSetatBoolean}[2]{%
+ \lowercase{\def\@tempa{#2}}%
+ \@ifundefined{@tempswa\@tempa}%
+ {\PackageError{biditools}%
+ {You can only set a boolean to `true' or `false'}\@ehc}%
+ {\@ifundefined{@#1\@tempa}%
+ {\PackageError{biditools}{Boolean @#1 undefined}\@ehc}%
+ {\global\csname @#1\@tempa\endcsname}}}
\def\@bidi@removefromreset#1#2{{%
\expandafter\let\csname c@#1\endcsname\@bidi@removefromreset
\def\@elt##1{%
@@ -4042,6 +4076,7 @@ ill-advised in the old versions of bidi package.%
\else
\expandafter\@secondoftwo
\fi}
+
\newcommand*{\if@bidi@csdef}[1]{%
\ifcsname#1\endcsname
\expandafter\@firstoftwo
@@ -5091,10 +5126,6 @@ bidi implementation of tufte float]
\newcommand{\bidituftefloatError}[2]{\PackageError{\@bidituftefloat@pkgname}{#1}{#2}}
\newcommand{\bidituftefloatDebugInfoNL}[1]{\ifthenelse{\boolean{@bidituftefloat@debug}}{\bidituftefloatInfoNL{#1}}{}}
\newcommand{\bidituftefloatInfoNL}[1]{\PackageInfo{\@bidituftefloat@pkgname}{#1\@gobble}}
-\newboolean{@bidituftefloat@RTLgeometry}
-\setboolean{@bidituftefloat@RTLgeometry}{true}
-\DeclareOption{RTLgeometry}{\setboolean{@bidituftefloat@RTLgeometry}{true}}
-\DeclareOption{LTRgeometry}{\setboolean{@bidituftefloat@RTLgeometry}{false}}
\newboolean{@bidituftefloat@afourpaper}
\DeclareOption{a4paper}{\setboolean{@bidituftefloat@afourpaper}{true}}
\newboolean{@bidituftefloat@bfivepaper}
@@ -5120,16 +5151,7 @@ bidi implementation of tufte float]
\setlength{#1}{#2}%
\global#1=#1\relax%
}
-%% Globally sets a boolean
-\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}%
- }%
-}
+
%% Set the font sizes and baselines to match bidituftefloat's books
\renewcommand\normalsize{%
\@setfontsize\normalsize\@xpt{14}%
@@ -5159,21 +5181,13 @@ bidi implementation of tufte float]
\setlength{\parskip}{0pt}%
}
\RequirePackage{ragged2e}
-\ifthenelse{\boolean{@bidituftefloat@RTLgeometry}}{%
-\RequirePackage[letterpaper,right=1in,top=1in,headsep=2\baselineskip,textwidth=26pc,marginparsep=2pc,marginparwidth=12pc,textheight=44\baselineskip,headheight=\baselineskip]{geometry}
-\ifthenelse{\boolean{@bidituftefloat@afourpaper}}
- {\geometry{a4paper,right=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=107mm,marginparsep=8.2mm,marginparwidth=49.4mm,textheight=49\baselineskip,headheight=\baselineskip}}
- {}
-\ifthenelse{\boolean{@bidituftefloat@bfivepaper}}
- {\geometry{paperwidth=176mm,paperheight=250mm,right=14.66mm,top=13.88mm,textwidth=102.66mm,marginparsep=7.33mm,marginparwidth=36.66mm,textheight=38\baselineskip,includehead}}
- {}}{%
\RequirePackage[letterpaper,left=1in,top=1in,headsep=2\baselineskip,textwidth=26pc,marginparsep=2pc,marginparwidth=12pc,textheight=44\baselineskip,headheight=\baselineskip]{geometry}
\ifthenelse{\boolean{@bidituftefloat@afourpaper}}
{\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=107mm,marginparsep=8.2mm,marginparwidth=49.4mm,textheight=49\baselineskip,headheight=\baselineskip}}
{}
\ifthenelse{\boolean{@bidituftefloat@bfivepaper}}
{\geometry{paperwidth=176mm,paperheight=250mm,left=14.66mm,top=13.88mm,textwidth=102.66mm,marginparsep=7.33mm,marginparwidth=36.66mm,textheight=38\baselineskip,includehead}}
- {}}
+ {}
\ifthenelse{\boolean{@bidituftefloat@symmetric}}
{}
{\geometry{asymmetric}}% forces internal LaTeX `twoside'
@@ -5263,8 +5277,8 @@ bidi implementation of tufte float]
\newcommand{\floatalignment}{x}% holds the current float alignment (t, b, h, p)
\newcommand{\setfloatalignment}[1]{\global\def\floatalignment{#1}\@bidituftefloat@float@debug{Forcing position: [#1]}}% manually sets the float alignment
\newboolean{@bidituftefloat@float@recto}
-\newcommand{\forcerectofloat}{\gsetboolean{@bidituftefloat@float@recto}{true}\@bidituftefloat@float@debug{Forcing page: [recto]}}
-\newcommand{\forceversofloat}{\gsetboolean{@bidituftefloat@float@recto}{false}\@bidituftefloat@float@debug{Forcing page: [verso]}}
+\newcommand{\forcerectofloat}{\GlobalSetBoolean{@bidituftefloat@float@recto}{true}\@bidituftefloat@float@debug{Forcing page: [recto]}}
+\newcommand{\forceversofloat}{\GlobalSetBoolean{@bidituftefloat@float@recto}{false}\@bidituftefloat@float@debug{Forcing page: [verso]}}
\newsavebox{\@bidituftefloat@figure@box}
\newsavebox{\@bidituftefloat@caption@box}
\let\@bidituftefloat@orig@float\@float
@@ -5291,13 +5305,13 @@ bidi implementation of tufte float]
{% begin @bidituftefloat@float
% Should this float be full-width or just text-width?
\ifthenelse{\equal{#3}{star}}%
- {\gsetboolean{@bidituftefloat@float@star}{true}}%
- {\gsetboolean{@bidituftefloat@float@star}{false}}%
+ {\GlobalSetBoolean{@bidituftefloat@float@star}{true}}%
+ {\GlobalSetBoolean{@bidituftefloat@float@star}{false}}%
% Check page side (recto/verso) and store detected value -- can be overriden in environment contents
\@bidituftefloat@checkoddpage%
\ifthenelse{\boolean{@bidituftefloat@odd@page}}%
- {\gsetboolean{@bidituftefloat@float@recto}{true}\@bidituftefloat@float@debug{Detected page: [recto/odd]}}%
- {\gsetboolean{@bidituftefloat@float@recto}{false}\@bidituftefloat@float@debug{Detected page: [verso/even]}}%
+ {\GlobalSetBoolean{@bidituftefloat@float@recto}{true}\@bidituftefloat@float@debug{Detected page: [recto/odd]}}%
+ {\GlobalSetBoolean{@bidituftefloat@float@recto}{false}\@bidituftefloat@float@debug{Detected page: [verso/even]}}%
% If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them.
\renewcommand{\@bidituftefloat@fps}{#1}%
\@bidituftefloat@float@debug{Allowed positions: [#1]}%
@@ -5584,8 +5598,8 @@ bidi implementation of tufte float]
\setboolean{@bidituftefloat@packages@subfigure}{false}
\AtBeginDocument{%
\@ifpackageloaded{subfigure}
- {\gsetboolean{@bidituftefloat@packages@subfigure}{true}}
- {\gsetboolean{@bidituftefloat@packages@subfigure}{false}}%
+ {\GlobalSetBoolean{@bidituftefloat@packages@subfigure}{true}}
+ {\GlobalSetBoolean{@bidituftefloat@packages@subfigure}{false}}%
}
\AtBeginDocument{%
\@ifpackageloaded{float}{%
@@ -5826,19 +5840,7 @@ bidi implementation of tufte sidenote]
\global#1=#1\relax%
}%
}{}
-%%
-% Globally sets a boolean
-\@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}%
- }%
-}%
-}{}
+
%%
% A function that removes leading and trailling spaces from the supplied macro.
% Based on code written by Michael Downes (See ``Around the Bend'', #15.)
@@ -12755,7 +12757,7 @@ bidi implementation of tufte title]
%\fi
% \subsection{\textsf{geometry-xetex-bidi.def}}
% \begin{macrocode}
-\ProvidesFile{geometry-xetex-bidi.def}[2013/04/01 v0.1 bidi adaptations for geometry package for XeTeX engine]
+\ProvidesFile{geometry-xetex-bidi.def}[2017/01/14 v0.2 bidi adaptations for geometry package for XeTeX engine]
\renewcommand*{\Gm@vrules@mpi}{%
\if@RTLmain%
\hb@xt@\@tempdima{\hskip-\marginparwidth\hskip-\marginparsep
@@ -12776,7 +12778,27 @@ bidi implementation of tufte title]
\llap{\Gm@vrule}\ignorespaces
\hskip \marginparwidth\rlap{\Gm@vrule}\hskip \marginparsep
\llap{\Gm@vrule}\hskip\textwidth\rlap{\Gm@vrule}\hss}\fi}%
-
+\bidi@patchcmd{\Gm@pageframes}{%
+ \ifodd\count\z@
+ \let\@themargin\oddsidemargin
+ \else
+ \let\@themargin\evensidemargin
+ \fi
+}{%
+ \ifodd\count\z@
+ \if@RTLmain
+ \let\@themargin\evensidemargin
+ \else
+ \let\@themargin\oddsidemargin
+ \fi
+ \else
+ \if@RTLmain
+ \let\@themargin\oddsidemargin
+ \else
+ \let\@themargin\evensidemargin
+ \fi
+ \fi
+}{}{}
% \end{macrocode}
% \iffalse
%</geometry-xetex-bidi.def>
@@ -13835,7 +13857,7 @@ bidi implementation of tufte title]
%\fi
% \subsection{\textsf{listings-xetex-bidi.def}}
% \begin{macrocode}
-\ProvidesFile{listings-xetex-bidi.def}[2016/11/08 v1.3 bidi adaptations for listings package for XeTeX engine]
+\ProvidesFile{listings-xetex-bidi.def}[2017/01/14 v1.4 bidi adaptations for listings package for XeTeX engine]
\lst@Key{captiondirection}{textdirection}{%
\lstKV@SwitchCases{#1}%
{textdirection&\\%
@@ -13843,9 +13865,9 @@ bidi implementation of tufte title]
LTR&\chardef\bidi@lst@caption@direction\z@%
}{\PackageError{Listings}{direction #1 unknown}\@ehc}}
-\lst@Key{captionscript}{latin}{%
+\lst@Key{captionscript}{textscript}{%
\lstKV@SwitchCases{#1}%
- {%
+ {textscript&\\%
latin&\chardef\bidi@lst@caption@script\@ne\\%
nonlatin&\chardef\bidi@lst@caption@script\z@%
}{\PackageError{Listings}{direction #1 unknown}\@ehc}}
@@ -13860,14 +13882,20 @@ bidi implementation of tufte title]
\fi%
\fi%
}}
-\long\def\@bidi@lst@makecaption#1#2{%
+
+\newcommand*{\bidi@lst@ensure@caption@script}[2]{%
+ \@ifundefined{bidi@lst@caption@script}{}{%
\ifnum\bidi@lst@caption@script=\z@%
- \@nonlatintrue%
+ #1%
\else%
\ifnum\bidi@lst@caption@script=\@ne%
- \@nonlatinfalse%
+ #2%
\fi%
\fi%
+}}
+
+\long\def\@bidi@lst@makecaption#1#2{%
+ \bidi@lst@ensure@caption@script{\@nonlatintrue}{\@nonlatinfalse}%
\vskip\abovecaptionskip
\bidi@lst@ensure@caption@direction{\@RTLfalse}{\@RTLtrue}%
\sbox\@tempboxa{%
@@ -13911,13 +13939,7 @@ bidi implementation of tufte title]
}
\@ifpackageloaded{caption}{%
\AtBeginCaption{%
- \ifnum\bidi@lst@caption@script=\z@%
- \@nonlatintrue%
- \else%
- \ifnum\bidi@lst@caption@script=\@ne%
- \@nonlatinfalse%
- \fi%
- \fi%
+ \bidi@lst@ensure@caption@script{\@nonlatintrue}{\@nonlatinfalse}%
\bidi@lst@ensure@caption@direction{\@RTLfalse}{\@RTLtrue}%
}
\let\@bidi@lst@makecaption\caption@makecaption%
@@ -21975,9 +21997,17 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi}
\fi
\if@twoside
\ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
+ \if@RTLmain
+ \let\@themargin\evensidemargin
+ \else
+ \let\@themargin\oddsidemargin
+ \fi
+ \else \let\@thehead\@evenhead \let\@thefoot\@evenfoot
+ \if@RTLmain
\let\@themargin\oddsidemargin
- \else \let\@thehead\@evenhead
- \let\@thefoot\@evenfoot \let\@themargin\evensidemargin
+ \else
+ \let\@themargin\evensidemargin
+ \fi
\fi
\ifx\@thehead\@empty \let\@thehead\hfil \fi
\ifx\@thefoot\@empty \let\@thefoot\hfil \fi