diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/bidi/bidi.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/bidi/bidi.dtx | 2576 |
1 files changed, 2437 insertions, 139 deletions
diff --git a/Master/texmf-dist/source/latex/bidi/bidi.dtx b/Master/texmf-dist/source/latex/bidi/bidi.dtx index e5570e1fd26..50d3b5c4fd3 100644 --- a/Master/texmf-dist/source/latex/bidi/bidi.dtx +++ b/Master/texmf-dist/source/latex/bidi/bidi.dtx @@ -5,16 +5,12 @@ %<*readme> ___________________ The bidi package -v1.1.7 +v1.2.4 This package provides a convenient interface for typesetting bidirectional texts in Plain TeX and LaTeX. -This version fixes all the bugs that were present in v1.1.5. - -Note: The image ctg.jpg is in public domain (a public domain -artwork from iranpoliticsclub.net) and taken from -http://iranpoliticsclub.net/culture-language/PIY/images/Cyrus%20The%20Great%20face.jpg +This version fixes all the bugs that were present in v1.2.3. ___________________ Vafa Khalighi @@ -75,6 +71,14 @@ by Vafa Khalighi. \generate{\file{bidicode.sty}{\from{\jobname.dtx}{bidicode.sty}}} \generate{\file{bidiftnxtra.sty}{\from{\jobname.dtx}{bidiftnxtra.sty}}} \generate{\file{bidimoderncv.cls}{\from{\jobname.dtx}{bidimoderncv.cls}}} +\generate{\file{bidituftefloat.sty}{\from{\jobname.dtx}{bidituftefloat.sty}}} +\generate{\file{bidituftesidenote.sty}{\from{\jobname.dtx}{bidituftesidenote.sty}}} +\generate{\file{bidituftetoc.sty}{\from{\jobname.dtx}{bidituftetoc.sty}}} +\generate{\file{bidituftegeneralstructure.sty}{\from{\jobname.dtx}{bidituftegeneralstructure.sty}}} +\generate{\file{bidituftehyperref.sty}{\from{\jobname.dtx}{bidituftehyperref.sty}}} +\generate{\file{bidituftetitle.sty}{\from{\jobname.dtx}{bidituftetitle.sty}}} +\generate{\file{biditufte-handout.cls}{\from{\jobname.dtx}{biditufte-handout.cls}}} +\generate{\file{biditufte-book.cls}{\from{\jobname.dtx}{biditufte-book.cls}}} \generate{\file{bidipoem.sty}{\from{\jobname.dtx}{bidipoem.sty}}} \generate{\file{bidipresentation.cls}{\from{\jobname.dtx}{bidipresentation.cls}}} \generate{\file{boek3-xetex-bidi.def}{\from{\jobname.dtx}{boek3-xetex-bidi.def}}} @@ -103,6 +107,7 @@ by Vafa Khalighi. \generate{\file{footnote-xetex-bidi.def}{\from{\jobname.dtx}{footnote-xetex-bidi.def}}} \generate{\file{framed-xetex-bidi.def}{\from{\jobname.dtx}{framed-xetex-bidi.def}}} \generate{\file{graphicx-xetex-bidi.def}{\from{\jobname.dtx}{graphicx-xetex-bidi.def}}} +\generate{\file{hvfloat-xetex-bidi.def}{\from{\jobname.dtx}{hvfloat-xetex-bidi.def}}} \generate{\file{hyperref-xetex-bidi.def}{\from{\jobname.dtx}{hyperref-xetex-bidi.def}}} \generate{\file{leqno-xetex-bidi.def}{\from{\jobname.dtx}{leqno-xetex-bidi.def}}} \generate{\file{letter-xetex-bidi.def}{\from{\jobname.dtx}{letter-xetex-bidi.def}}} @@ -114,6 +119,7 @@ by Vafa Khalighi. \generate{\file{minitoc-xetex-bidi.def}{\from{\jobname.dtx}{minitoc-xetex-bidi.def}}} \generate{\file{multicol-xetex-bidi.def}{\from{\jobname.dtx}{multicol-xetex-bidi.def}}} \generate{\file{multienum-xetex-bidi.def}{\from{\jobname.dtx}{multienum-xetex-bidi.def}}} +\generate{\file{natbib-xetex-bidi.def}{\from{\jobname.dtx}{natbib-xetex-bidi.def}}} \generate{\file{pdfpages-xetex-bidi.def}{\from{\jobname.dtx}{pdfpages-xetex-bidi.def}}} \generate{\file{pgf-xetex-bidi.def}{\from{\jobname.dtx}{pgf-xetex-bidi.def}}} \generate{\file{plain-luatex-bidi.def}{\from{\jobname.dtx}{plain-luatex-bidi.def}}} @@ -129,6 +135,7 @@ by Vafa Khalighi. \generate{\file{scrbook-xetex-bidi.def}{\from{\jobname.dtx}{scrbook-xetex-bidi.def}}} \generate{\file{scrlettr-xetex-bidi.def}{\from{\jobname.dtx}{scrlettr-xetex-bidi.def}}} \generate{\file{scrreprt-xetex-bidi.def}{\from{\jobname.dtx}{scrreprt-xetex-bidi.def}}} +\generate{\file{sidecap-xetex-bidi.def}{\from{\jobname.dtx}{sidecap-xetex-bidi.def}}} \generate{\file{stabular-xetex-bidi.def}{\from{\jobname.dtx}{stabular-xetex-bidi.def}}} \generate{\file{subfigure-xetex-bidi.def}{\from{\jobname.dtx}{subfigure-xetex-bidi.def}}} \generate{\file{tabls-xetex-bidi.def}{\from{\jobname.dtx}{tabls-xetex-bidi.def}}} @@ -175,20 +182,16 @@ by Vafa Khalighi. % %<*driver> \documentclass{ltxdoc} -\usepackage{graphicx,wrapfig,fontspec} \usepackage{calc} \usepackage{pifont} \usepackage{bbding} \usepackage{bidicode} \usepackage[numbered]{hypdoc} -\definecolor{bidiblue}{rgb}{0.1,0.2,0.8} -\hypersetup{linkcolor=bidiblue,urlcolor=bidiblue,citecolor=bidiblue} +\hypersetup{pdftitle={The \textsf{bidi} Package (Support for bidirectional typesetting in plain \TeX{} and \LaTeXe)},pdfauthor={Vafa Khalighi <vafa018@gmail.com>}} \setlength\columnseprule{.4pt} -\setmainfont[Mapping=tex-text,Numbers=OldStyle]{Junicode} \newcommand\XeTeX{Xe\TeX} \newcommand\XeLaTeX{Xe\LaTeX} \makeatletter -\@addtoreset{CodelineNo}{subsection} \pdfstringdefDisableCommands{% \renewcommand\Lcs[1]{\textbackslash#1} } @@ -208,7 +211,7 @@ by Vafa Khalighi. \EnableCrossrefs \CodelineIndex \RecordChanges -%\OnlyDescription +\OnlyDescription \begin{document} \DocInput{\jobname.dtx} \PrintIndex @@ -222,27 +225,12 @@ by Vafa Khalighi. % \GetFileInfo{\jobname.sty} % \CheckSum{0} % \makeatletter -% \changes{v1.1.7}{2011/03/21}{Update the documentation.} -% \title{The \textsf{bidi} package\\ \href{http://bitbucket.org/vafa/bidi}{\texttt{http://bitbucket.org/vafa/bidi}}} -% \author{\textsc{Vafa Khalighi}\\ \href{mailto:vafa018@gmail.com}{\texttt{vafa018@gmail.com}}} -% \date{\today \qquad v1.1.7} -% +% \title{The \textsf{bidi} Package\\ \url{https://bitbucket.org/vafa/bidi}\\[5pt] +% Support for bidirectional typesetting in plain \TeX{} and \LaTeXe} +% \author{Vafa Khalighi\\ +% \url{vafa018@gmail.com}} +% \date{\today\qquad Version 1.2.4} % \maketitle -%\section{Dedication} -%\textit{We dedicate the \textsf{bidi} package to our \textbf{father}, \textbf{Cyrus The Great}.} -%\textbf{Cyrus the Great} (c. 600 BC or 576 BC – December 530 BC), also known as \textbf{Cyrus II} or \textbf{Cyrus of Persia}, was the first Zoroastrian Persian emperor. He was the founder of the Persian Empire under the Achaemenid dynasty. -% -%\begin{wrapfigure}{l}{0.5\textwidth} -%\centering -%\fbox{\includegraphics{ctg}} -% \caption{Portrait of Cyrus The Great} -%\end{wrapfigure} -% -%It was under his own rule that the empire embraced all previous civilized states of the ancient Near East, expanded vastly and eventually conquered most of Southwest Asia and much of Central Asia, from Egypt and the Hellespont in the west to the Indus River in the east, to create the largest empire the world had yet seen. -% -%The reign of Cyrus lasted 29 to 31 years. Cyrus built his empire by fighting and conquering first the Median Empire, then the Lydian Empire and the Neo-Babylonian Empire. Either before or after Babylon, he led an expedition into central Asia, which resulted in major campaigns that brought ``into subjection every nation without exception." Cyrus did not venture into Egypt, as he himself died in battle, fighting the Massagetae along the Syr Darya in December 530 BC. He was succeeded by his son, Cambyses II, who managed to add to the empire by conquering Egypt, Nubia, and Cyrenaica during his short rule. -% -%As a military leader, Cyrus left a legacy on the art of leadership and decision making, and he attributed his success to ``Diversity in counsel, unity in command.'' Cyrus the Great respected the customs and religions of the lands he conquered. It is said that in universal history, the role of the Achaemenid empire founded by Cyrus lies in its very successful model for centralized administration and establishing a government working to the advantage and profit of its subjects. In fact, the administration of the empire through satraps and the vital principle of forming a government at Pasargadae were the work of Cyrus. Aside from his own nation, Iran, Cyrus also left a lasting legacy on Jewish religion (through his Edict of Restoration), human rights, politics, and military strategy, as well as on both Eastern and Western civilizations. % \tableofcontents %\section{Introduction} %\textsf{bidi} provides a convenient interface for typesetting bidirectional texts in plain \TeX\ and \LaTeX. @@ -250,15 +238,15 @@ by Vafa Khalighi. %The \textsf{bidi} package at the moment only works with \XeTeX\ engine, but we will support other \TeX\ engines as well in the future. %\subsection{\textsf{bidi} Info On The Terminal and In The Log File} %If you use \textsf{bidi} package to write any input \TeX\ document, and then run \texttt{xelatex} on your document, \textsf{bidi} writes some information about itself to the terminal and to the log file. The information is something like: -%\begin{lstlisting}[backgroundcolor=\color{blue!20}] +%\begin{lstlisting}[backgroundcolor=\color{blue!20},numbers=none,frame=none,framexleftmargin=1mm] %bidi package (Support for bidirectional typesetting in plain TeX and LaTeX) %Description: A convenient interface for typesetting bidirectional texts %in plain TeX and LaTeX. The package includes adaptations for use %with many other commonly-used packages. %Copyright (c) 2009-2011 Vafa Khalighi -%v1.1.7, <commit 150>, 2011/03/21 +%v1.2.4, 2011/08/01 %License: LaTeX Project Public License, version 1.3c or higher (your choice) -%Home: http://bitbucket.org/vafa/bidi +%Home: https://bitbucket.org/vafa/bidi %Location on CTAN: /macros/latex/contrib/bidi %\end{lstlisting} %\section{Basics} @@ -286,10 +274,8 @@ by Vafa Khalighi. %\end{document} %\end{lstlisting} %Where \textsf{graphicx} is loaded after \textsf{bidi}. If you run \texttt{xelatex} on this document, you will get an error which looks like this: -%\begin{lstlisting}[backgroundcolor=\color{blue!20}] -%! Package bidi Error: Oops! you have loaded package graphicx after bidi package -%. Please load package graphicx before bidi package, and then try to run xelatex -% on your document again. +%\begin{lstlisting}[backgroundcolor=\color{blue!20},numbers=none,frame=none,framexleftmargin=1mm] +%! Package bidi Error: Oops! you have loaded package graphicx after bidi package. Please load package graphicx before bidi package, and then try to run xelatex on your document again. % %See the bidi package documentation for explanation. %Type H <return> for immediate help. @@ -301,41 +287,52 @@ by Vafa Khalighi. % %\end{lstlisting} %\end{enumerate} -%\subsection{Commands for Version number, Mercurial commit number and Date of The Package} +%\subsection{Commands for Version number, and Date of The Package} %\begin{BDef} -%\Lcs{bidiversion}\quad\Lcs{bidicommit}\quad\Lcs{bididate} +%\Lcs{bidiversion}\quad\Lcs{bididate} %\end{BDef} %\begin{itemize} %\item \Lcs{bidiversion} gives the current version of the package. -%\item \Lcs{bidicommit} gives the current Mercurial commit number of the package. %\item \Lcs{bididate} gives the current date of the package. %\end{itemize} %\begin{lstlisting} %\documentclass{article} %\usepackage{bidi} %\begin{document} -%This is typeset by \textsf{bidi} package, \bidiversion, \bidicommit, \bididate. +%This is typeset by \textsf{bidi} package, \bidiversion, \bididate. %\end{document} %\end{lstlisting} +%\subsection{Turning TeX-{-}XeT features on and off} +%The bidirectional typesetting in \XeTeX{} is based on TeX-{-}XeT algorithm and \textsf{bidi} package automatically turns the feature on for typesetting bidirectional texts. As the internal data structures built by TeX-{-}XeT differ from those built by \TeX, the typesetting of a document by TeX-{-}XeT may therefore differ from that performed by \TeX. So you may notice that some packages behave differently when TeX-{-}XeT feature is on and you may want to turn the feature off for a part of the text so that you get the default behaviour of original \TeX. Two commands are provided for this purpose: +%\begin{BDef} +%\Lcs{TeXXeTOn}\quad\Lcs{TeXXeTOff} +%\end{BDef} +%\begin{itemize} +%\item \Lcs{TeXXeTOn} turns TeX-{-}XeT feature on, which is active by default when \textsf{bidi} package is loaded. +%\item \Lcs{TeXXeTOff} turns TeX-{-}XeT feature off. +%\end{itemize} %\subsection{Options of The Package\label{options}} %There are three options, namely \texttt{RTLdocument} and \texttt{rldocument}, which are essentialy equivalent. If you pass any of these options to the package, you will be typesetting a document containing mainly RTL texts with some LTR texts. These options activate \Lcs{setRTL} (explained in \autoref{PSC}), \Lcs{RTLdblcol} (explained in \autoref{twocolumn}) and \Lcs{autofootnoterule} (explained in \autoref{footnoterule}). % %It is clear that if you do not pass any of these options to the package, you will be typesetting a document containing mainly LTR texts with some RTL texts. % -%\marginpar{\bfseries\textcolor{red}{New Option}$\longrightarrow$}There is also \texttt{extrafootnotefeatures} option that allows footnotes to be typeset in different formats: +%There is also \texttt{extrafootnotefeatures} option that allows footnotes to be typeset in different formats: %\begin{BDef} %\Lcs{normalfootnotes}\\ %\Lcs{twocolumnfootnotes}\quad\Lcs{threecolumnfootnotes}\quad\Lcs{fourcolumnfootnotes}\\ %\Lcs{fivecolumnfootnotes}\quad\Lcs{sixcolumnfootnotes}\quad\Lcs{sevencolumnfootnotes}\\ %\Lcs{eightcolumnfootnotes}\quad\Lcs{ninecolumnfootnotes}\quad\Lcs{tencolumnfootnotes}\\ %\Lcs{RTLcolumnfootnotes}\quad\Lcs{LTRcolumnfootnotes}\\ -%\Lcs{paragraphfootnotes} +%\Lcs{paragraphfootnotes}\\ +%\Lcs{setLTRparagraphfootnotes}\quad\Lcs{setRTLparagraphfootnotes} %\end{BDef} %\begin{itemize} %\item \Lcs{normalfootnotes} typesets footnotes in Standard \LaTeX{} format. %\item \Lcs{twocolumnfootnotes} to \Lcs{tencolumnfootnotes}, typeset footnotes in two-columns to ten-columns, respectively. %\item \Lcs{RTLcolumnfootnotes} typesets footnotes columns RTL (first column on the RHS and each next column to the left of the previous column) and \Lcs{LTRcolumnfootnotes} typesets footnotes columns LTR (first column on the LHS and each next column to the right of the previous column). \Lcs{LTRcolumnfootnotes} is active by default. %\item \Lcs{paragraphfootnotes} typesets footnotes in paragraph format. +%\item \Lcs{setLTRparagraphfootnotes} makes footnotes run from left to right. This comand is active by default. +%\item \Lcs{setRTLparagraphfootnotes} makes footnotes run from right to left. %\item When using \texttt{extrafootnotefeatures}, \Lcs{textwidthfootnoterule} is active. %\end{itemize} %\subsection{Paragraph Switching Commands\label{PSC}} @@ -540,7 +537,8 @@ by Vafa Khalighi. %\begin{document} %\leavevmode\hbox{This is a Test} %\end{document} -%\end{lstlisting}\subsection{\Lcs{bidillap} and \Lcs{bidirlap} Commands} +%\end{lstlisting} +%\subsection{\Lcs{bidillap} and \Lcs{bidirlap} Commands} %In RTL mode, \Lcs{llap} and \Lcs{rlap} do oposite things. Since these two macros are used in a lot of classes and packages, instead modifying these two macros, we have created two new macros \Lcs{bidillap} and \Lcs{bidirlap} which give logical results. %\subsection{\textsf{LTRitems} and \textsf{RTLitems} Environments} %If you typeset an \textsf{itemize}, or an \textsf{enumerate}, or a \textsf{description} environment where all \Lcs{item}s are one directional, you have no problem at all as shown below: @@ -596,6 +594,14 @@ by Vafa Khalighi. %\LEND{LTRitems} %\end{BDef} %Where \OptArg{length} is optional and if you do not give it, the value of \Lcs{leftskip} will be equal to the value of \Lcs{labelwidth}\(+\)\Lcs{labelsep} by default and if you give this optional length, then the value of \Lcs{leftskip} will be equal to the value of \Lcs{labelwidth}\(+\)\Larg{given length}. +%\subsection{\textsf{LTRbibitems} and \textsf{RTLbibitems} Environments} +%The syntax of \textsf{LTRbibitems} and \textsf{RTLbibitems} environments is exactly like the syntax of \textsf{LTRitems} and \textsf{RTLitems} environments but there are few differences: +%\begin{itemize} +%\item \textsf{LTRitems} and \textsf{RTLitems} environments should only be used for \textsf{list}-like environments (such as \textsf{itemize}, \textsf{enumerate} and \textsf{description} environments) but \textsf{LTRbibitems} and \textsf{RTLbibitems} environments should only be used for \textsf{thebibliography} environment. +%\item Clearly instead of \Lcs{item}, you have \Lcs{bibitem} inside \textsf{LTRbibitems} and \textsf{RTLbibitems} environments. +%\item For \textsf{LTRbibitems} environment, if \textsf{natbib} package with \texttt{authoryear}\footnote{\texttt{authoryear} option is the default when \textsf{natbib} package is loaded.} option is loaded and if you do not specify the optional \OptArg{length}, then the value of \Lcs{leftskip} will be equal to the value of 2\Lcs{labelsep} by default and if you give this optional length, then the value of \Lcs{leftskip} will be equal to the value of \Lcs{labelsep}\(+\)\Larg{given length}. +%\item For \textsf{RTLbibitems} environment, if \textsf{natbib} package with \texttt{authoryear} option is loaded and if you do not specify the optional \OptArg{length}, then the value of \Lcs{rightskip} will be equal to the value of 2\Lcs{labelsep} by default and if you give this optional length, then the value of \Lcs{rightskip} will be equal to the value of \Lcs{labelsep}\(+\)\Larg{given length}. +%\end{itemize} %\subsection{\Lcs{setLTRbibitems}, \Lcs{setRTLbibitems}, and \Lcs{setdefaultbibitems} commands} %\begin{BDef} %\Lcs{setLTRbibitems}\quad\Lcs{setRTLbibitems}\quad\Lcs{setdefaultbibitems} @@ -612,23 +618,28 @@ by Vafa Khalighi. %\begin{document} %\begin{thebibliography}{99} %\bibitem This is the first bibitem which is LTR. -%\begin{RTLitems} +%\begin{RTLbibitems} %\bibitem This is the second bibitem which is RTL. -%\end{RTLitems} +%\end{RTLbibitems} %\end{thebibliography} %\end{document} %\end{lstlisting} %\end{itemize} % %\subsection{Typesetting margin par} -%By default, in RTL mode, \Lcs{marginpar} appears on LHS and its content is typeset RTL and in LTR mode, \Lcs{marginpar} appears on RHS and its content is typeset LTR. In addition, the three following commands are provided: +%By default, in RTL mode, \Lcs{marginpar} appears on LHS and its content is typeset RTL and in LTR mode, \Lcs{marginpar} appears on RHS and its content is typeset LTR. In addition, the following commands are provided: %\begin{BDef} -%\Lcs{setRTLmarginpar}\quad\Lcs{setLTRmarginpar}\quad\Lcs{setdefaultmarginpar} +%\Lcs{setRTLmarginpar}\quad\Lcs{setLTRmarginpar}\quad\Lcs{setdefaultmarginpar}\\ +%\Lcs{LTRmarginpar}\Largs{\Larga{left-text}}\Largb{\Larga{right-text}}\\ +%\Lcs{RTLmarginpar}\Largs{\Larga{left-text}}\Largb{\Larga{right-text}} %\end{BDef} %\begin{itemize} %\item \Lcs{setRTLmarginpar} always makes \Lcs{marginpar} to appear on LHS and the content of \Lcs{marginpar} is typeset RTL (this is independent of the current mode). %\item \Lcs{setLTRmarginpar} always makes \Lcs{marginpar} to appear on RHS and the content of \Lcs{marginpar} is typeset LTR (this is independent of the current mode). %\item \Lcs{setdefaultmarginpar} gives the default behaviour of \Lcs{marginpar} as described above. +%\item \Lcs{LTRmarginpar} typesets \Larga{left-text} and \Larga{right-text} always LTR. +%\item \Lcs{RTLmarginpar} typesets \Larga{left-text} and \Larga{right-text} always RTL. +%\item in RTL mode, places of \Larga{left-text} and \Larga{right-text} swaps. %\end{itemize} %\subsection{Typesetting of Headers and Footers} %If the main direction of the document is RTL, then headers and footers are typeset RTL and if the main direction of the document is LTR, then headers and footers are typeset LTR. @@ -637,7 +648,7 @@ by Vafa Khalighi. %\subsection{Equation Numbers} %For \texttt{reqno}, equation numbers are on the right hand side and for \texttt{leqno}, equation numbers are on the left hand side, independent on the current mode. %\section{Support For Various Packages and Classes} -%The \textsf{bidi} package supports \textsf{amsmath}, \textsf{amsthm}, \textsf{array}, \textsf{arydshln}, \textsf{breqn}, \textsf{caption}, \textsf{color}, \textsf{colortbl}, \textsf{dblfnote} \textsf{draftwatermark}, \textsf{empheq}, \textsf{fancyhdr}, \textsf{float}, \textsf{flowfram}, \textsf{framed}, \textsf{graphicx}, \textsf{hyperref}, \textsf{listings}, \textsf{minitoc}, \textsf{multicol}, \textsf{multienum}, \textsf{pdfpages}, \textsf{pstricks}, \textsf{quotchap}, \textsf{ragged2e}, \textsf{stabular}, \textsf{subfig}, \textsf{subfigure}, \textsf{supertabular}, \textsf{xtab}, \textsf{tabls}, \textsf{tabulary}, \textsf{PGF \&\ TIKZ}, \textsf{tocbibind}, \textsf{tocloft}, \textsf{tocstyle}, \textsf{wrapfig}, \textsf{xcolor}, \textsf{xltxtra} packages, \textsf{amsart}, \textsf{amsbook}, \textsf{artikel1}, \textsf{artikel2}, \textsf{artikel3}, \textsf{extarticle}, \textsf{standrad article}, \textsf{boek}, \textsf{boek3}, \textsf{standard book}, \textsf{bookest}, \textsf{extbook}, \textsf{extletter}, \textsf{scrlettr},\textsf{standard letter}, \textsf{memoir}, \textsf{extreport}, \textsf{rapport1}, \textsf{rapport3}, \textsf{refrep}, \textsf{standard report}, \textsf{scartcl}, \textsf{scrbook}, \textsf{scrreprt} classes and any other packages and classes that relies on these packages and classes. This means, you can use all these packages and classes in addition to other packages and classes that rely on these packages and classes and use their functionality fully for your bidirectional documents. +%The \textsf{bidi} package supports \textsf{amsmath}, \textsf{amsthm}, \textsf{array}, \textsf{arydshln}, \textsf{breqn}, \textsf{caption}, \textsf{color}, \textsf{colortbl}, \textsf{dblfnote} \textsf{draftwatermark}, \textsf{empheq}, \textsf{fancyhdr}, \textsf{float}, \textsf{flowfram}, \textsf{framed}, \textsf{graphicx}, \textsf{hvfloat}, \textsf{hyperref}, \textsf{listings}, \textsf{minitoc}, \textsf{multicol}, \textsf{multienum}, \textsf{pdfpages}, \textsf{pstricks}, \textsf{quotchap}, \textsf{ragged2e}, \textsf{sidecap}, \textsf{stabular}, \textsf{subfig}, \textsf{subfigure}, \textsf{supertabular}, \textsf{xtab}, \textsf{tabls}, \textsf{tabulary}, \textsf{PGF \&\ TIKZ}, \textsf{tocbibind}, \textsf{tocloft}, \textsf{tocstyle}, \textsf{wrapfig}, \textsf{xcolor}, \textsf{xltxtra} packages, \textsf{amsart}, \textsf{amsbook}, \textsf{artikel1}, \textsf{artikel2}, \textsf{artikel3}, \textsf{extarticle}, \textsf{flashcards}, \textsf{standrad article}, \textsf{boek}, \textsf{boek3}, \textsf{standard book}, \textsf{bookest}, \textsf{extbook}, \textsf{extletter}, \textsf{scrlettr},\textsf{standard letter}, \textsf{memoir}, \textsf{extreport}, \textsf{rapport1}, \textsf{rapport3}, \textsf{refrep}, \textsf{standard report}, \textsf{scartcl}, \textsf{scrbook}, \textsf{scrreprt} classes and any other packages and classes that relies on these packages and classes. This means, you can use all these packages and classes in addition to other packages and classes that rely on these packages and classes and use their functionality fully for your bidirectional documents. % %We now give some details that you should know about the supported packages or classes. %\subsection{Color} @@ -657,7 +668,8 @@ by Vafa Khalighi. % %In addition, you also can use \textsf{vwcol} package for variable width bidirectional column typesetting. %\section{Extra \textsf{bidi} Packages and Classes} -%\subsection{The Issue of Footnote} +%\subsection{Typesetting \TeX{} and \LaTeX{} Codes} +%The \LaTeX{} codes in this manual are typeset using the \textsf{bidicode} package. %In standard \LaTeX\, you can not use footnotes inside \Lcs{chapter}, \Lcs{part}, \Lcs{section}, \Lcs{subsection}, \Lcs{subsection} and any other section-like commands, \Lcs{caption} and tabular environment. % %\textsf{bidi} package provides \textsf{bidiftnxtra} package that solves the issue of footnote in standard \LaTeX. \textsf{bidiftnxtra} package should be loaded after \textsf{bidi} package. @@ -2220,10 +2232,9 @@ by Vafa Khalighi. % \subsection{\textsf{bidi.sty}} % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\def\bididate{2011/03/21} -\def\bidiversion{v1.1.7} -\def\bidicommit{commit 150} -\ProvidesPackage{bidi}[\bididate\space \bidiversion\space <\bidicommit> +\def\bididate{2011/08/01} +\def\bidiversion{v1.2.4} +\ProvidesPackage{bidi}[\bididate\space \bidiversion\space Bidirectional typesetting in plain TeX and LaTeX] \edef\bidiinfo{% bidi package (Support for bidirectional typesetting in plain TeX and LaTeX)^^J @@ -2231,9 +2242,9 @@ Description: A convenient interface for typesetting bidirectional^^J texts in plain TeX and LaTeX. The package includes adaptations for use^^J with many other commonly-used packages.^^J Copyright © 2009–2011 Vafa Khalighi^^J -\bidiversion, <\bidicommit>, \bididate^^J +\bidiversion, \bididate^^J License: LaTeX Project Public License, version 1.3c or higher (your choice)^^J -Home: http://bitbucket.org/vafa/bidi^^J +Home: https://bitbucket.org/vafa/bidi^^J Location on CTAN: /macros/latex/contrib/bidi} \typeout{\bidiinfo} \edef\bidi@everyjob{\the\everyjob} @@ -2254,7 +2265,6 @@ Location on CTAN: /macros/latex/contrib/bidi} \newif\if@RTLbibitems \newif\if@sentdir \newif\if@RTL@footnote -\newif\if@developmentversion \let\if@rlmain=\if@RTLmain \let\@rlmaintrue=\@RTLmaintrue \let\@rlmainfalse=\@RTLmainfalse @@ -2282,7 +2292,6 @@ Location on CTAN: /macros/latex/contrib/bidi} \def\pRLE{\protect\afterassignment\moreRLE \let\n@xt= } \def\bracetext{\ifcat\n@xt{\else\ifcat\n@xt}\fi \errmessage{Missing left brace has been substituted}\fi \bgroup} -\input{loadingorder-bidi.def} \ifXeTeX \input{xetex-bidi.def} \else @@ -2292,10 +2301,7 @@ Location on CTAN: /macros/latex/contrib/bidi} \PackageError{bidi}{TeX engines other than XeTeX and LuaTeX are not yet supported}{} \fi \fi -%\@developmentversiontrue -\if@developmentversion - \PackageWarningNoLine{bidi}{Thanks for testing the development version of bidi package. The development version may not work correctly or may not work at all. The development version is not recommended to be used for production purposes and should only be used for testing purposes. You are encouraged to use the stable version of bidi package available on CTAN for production purposes} -\fi +\input{loadingorder-bidi.def} \ProcessOptions % \end{macrocode} % \iffalse @@ -2304,19 +2310,19 @@ Location on CTAN: /macros/latex/contrib/bidi} %\fi % \subsection{\textsf{bidi.tex}} % \begin{macrocode} -\def\bididate{2011/03/21} +\def\bididate{2011/08/01} \def\bidiversion{v0.1} -\def\bidicommit{commit 150} \catcode`@=11 +\newlinechar`\^^J \edef\bidiinfo{% bidi package (Support for bidirectional typesetting in plain TeX and LaTeX)^^J Description: A convenient interface for typesetting bidirectional^^J texts in plain TeX and LaTeX. The package includes adaptations for use^^J with many other commonly-used packages.^^J Copyright © 2009–2011 Vafa Khalighi^^J -\bidiversion, <\bidicommit>, \bididate^^J +\bidiversion, \bididate^^J License: LaTeX Project Public License, version 1.3c or higher (your choice)^^J -Home: http://bitbucket.org/vafa/bidi^^J +Home: https://bitbucket.org/vafa/bidi^^J Location on CTAN: /macros/latex/contrib/bidi} \message{\bidiinfo} \edef\bidi@everyjob{\the\everyjob} @@ -2444,21 +2450,21 @@ Location on CTAN: /macros/latex/contrib/bidi} extendedchars=true, showspaces=false, showstringspaces=false, + numbers=left, + numbersep=0.9em, + numberstyle=\tiny, % + frame=single, captionpos=b, xleftmargin=1em, breaklines=true, - breakautoindent=true, + breakautoindent=false, + breakindent=0pt, escapeinside=**, - pos=b, + pos=r, explpreset={% xleftmargin=1em,columns=flexible,language=[LaTeX]TEX}, - morekeywords={setLTR,setLR,setRTL,setRL,LRE,LR,RLE,RL,lr,bidiversion,bididate,% - bidicommit} + morekeywords={setLTR,setLR,setRTL,setRL,LRE,LR,RLE,RL,lr,bidiversion,bididate} } -\lstdefinestyle{syntax}{backgroundcolor=\color{blue!20},numbers=none,xleftmargin=0pt,xrightmargin=0pt,pos=b} -\lstdefinestyle{code}{backgroundcolor=\color{red!20},numbers=none,xleftmargin=0pt,xrightmargin=0pt,pos=b} -\lst@UserCommand\lstlistlistingname{List of Examples} % \lstlistoflistings -\lst@UserCommand\lstlistingname{Example} \newcommand\HLON{% \gdef\lst@alloverstyle##1{% \fboxrule=0pt @@ -2966,6 +2972,1643 @@ Location on CTAN: /macros/latex/contrib/bidi} % \end{macrocode} % \iffalse %</bidimoderncv.cls> +%<*bidituftefloat.sty> +%\fi +% \subsection{\textsf{bidituftefloat.sty}} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bidituftefloat}[2011/06/14 v0.1 +bidi implementation of tufte float] +\RequirePackage{xifthen} +\newcommand{\@bidituftefloat@pkgname}{bidituftefloat} +\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} +\DeclareOption{b5paper}{\setboolean{@bidituftefloat@bfivepaper}{true}} +\newboolean{@bidituftefloat@symmetric} +\newboolean{@bidituftefloat@twoside} +\DeclareOption{twoside}{% +\@twosidetrue \@mparswitchtrue% +\setboolean{@bidituftefloat@twoside}{true}% +\setboolean{@bidituftefloat@symmetric}{true}% +} +\DeclareOption{oneside}{% +\@twosidefalse \@mparswitchfalse% +\setboolean{@bidituftefloat@twoside}{false}% +\setboolean{@bidituftefloat@symmetric}{false}% +} +\@ifclassloaded{book}{\ExecuteOptions{twoside}}{} +\newboolean{@bidituftefloat@debug} +\newcommand*{\@bidituftefloat@caption@justification}{\@bidituftefloat@justification@autodetect} +\ProcessOptions +%% Globally sets the length +\newcommand*{\gsetlength}[2]{% + \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}% + \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ + \abovedisplayshortskip \z@ \@plus3\p@ + \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ + \belowdisplayskip \abovedisplayskip + \let\@listi\@listI} +\normalbaselineskip=14pt +\normalsize +\renewcommand\footnotesize{% + \@setfontsize\footnotesize\@viiipt{10}% + \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@ + \abovedisplayshortskip \z@ \@plus\p@ + \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@ + \def\@listi{\leftmargin\leftmargini + \topsep 3\p@ \@plus\p@ \@minus\p@ + \parsep 2\p@ \@plus\p@ \@minus\p@ + \itemsep \parsep}% + \belowdisplayskip \abovedisplayskip +} +%% Paragraph indentation and separation for marginal text +\newcommand{\@bidituftefloat@margin@par}{% + \setlength{\RaggedRightParindent}{0.5pc}% + \setlength{\JustifyingParindent}{0.5pc}% + \setlength{\parindent}{0.5pc}% + \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' +\setlength\marginparpush{10pt} +%% Font for margin items +\newcommand{\@bidituftefloat@marginfont}{\normalfont\footnotesize} +\newcommand*{\@bidituftefloat@caption@font}{\@bidituftefloat@marginfont} +\newcommand*{\setcaptionfont}[1]{\renewcommand*{\@bidituftefloat@caption@font}{#1}} +\newcommand{\@bidituftefloat@justification}{\justifying}% +\setlength\abovedisplayskip{6pt plus 2pt minus 4pt} +\setlength\belowdisplayskip{6pt plus 2pt minus 4pt} +\newboolean{@bidituftefloat@changepage} +\IfFileExists{changepage.sty}{% + \bidituftefloatDebugInfoNL{Found changepage.sty} + \RequirePackage[strict]{changepage} + \setboolean{@bidituftefloat@changepage}{true} +}{% + \bidituftefloatDebugInfoNL{Found chngpage.sty} + \RequirePackage[strict]{chngpage} + \setboolean{@bidituftefloat@changepage}{false} +} +\newboolean{@bidituftefloat@odd@page} +\setboolean{@bidituftefloat@odd@page}{true} +\newcommand*{\@bidituftefloat@checkoddpage}{% + \checkoddpage% + \ifthenelse{\boolean{@bidituftefloat@changepage}}{% + \ifoddpage% + \setboolean{@bidituftefloat@odd@page}{true}% + \else% + \setboolean{@bidituftefloat@odd@page}{false}% + \fi% + }{% + \ifcpoddpage% + \setboolean{@bidituftefloat@odd@page}{true}% + \else% + \setboolean{@bidituftefloat@odd@page}{false}% + \fi% + }% +} +\newlength{\@bidituftefloat@overhang}% used by the fullwidth environment and the running heads +\newlength{\@bidituftefloat@fullwidth} +\newlength{\@bidituftefloat@caption@fill} +\newcommand{\bidituftefloatRecalculate}{% + \setlength{\@bidituftefloat@overhang}{\marginparwidth} + \addtolength{\@bidituftefloat@overhang}{\marginparsep} + + \setlength{\@bidituftefloat@fullwidth}{\textwidth} + \addtolength{\@bidituftefloat@fullwidth}{\marginparsep} + \addtolength{\@bidituftefloat@fullwidth}{\marginparwidth} + + \setlength{\@bidituftefloat@caption@fill}{\textwidth} + \addtolength{\@bidituftefloat@caption@fill}{\marginparsep} +} +\AtBeginDocument{\bidituftefloatRecalculate} +\RequirePackage{optparams}% provides multiple optional arguments for commands +\RequirePackage{placeins} +\newsavebox{\@bidituftefloat@margin@floatbox} +\newenvironment{@bidituftefloat@margin@float}[2][-1.2ex]% + {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order. + \begin{lrbox}{\@bidituftefloat@margin@floatbox}% + \begin{minipage}{\marginparwidth}% + \@bidituftefloat@caption@font% + \def\@captype{#2}% + \hbox{}\vspace*{#1}% + \@bidituftefloat@caption@justification% + \@bidituftefloat@margin@par% + \noindent% + } + {\end{minipage}% + \end{lrbox}% + \marginpar{\usebox{\@bidituftefloat@margin@floatbox}}% + } +\newenvironment{marginfigure}[1][-1.2ex]% + {\begin{@bidituftefloat@margin@float}[#1]{figure}} + {\end{@bidituftefloat@margin@float}} +\newenvironment{margintable}[1][-1.2ex]% + {\begin{@bidituftefloat@margin@float}[#1]{table}} + {\end{@bidituftefloat@margin@float}} +\newcommand*{\@bidituftefloat@justification@autodetect}{\justifying}% + +\newcommand{\@bidituftefloat@float@debug@info}{}% contains debug info generated as the float is processed +\newcommand{\@bidituftefloat@float@debug}[1]{% adds debug info to the queue for output + \ifthenelse{\equal{\@bidituftefloat@float@debug@info}{}}% + {\def\@bidituftefloat@float@debug@info{#1}}% + {\g@addto@macro\@bidituftefloat@float@debug@info{\MessageBreak#1}}% +} +\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]}} +\newsavebox{\@bidituftefloat@figure@box} +\newsavebox{\@bidituftefloat@caption@box} +\let\@bidituftefloat@orig@float\@float +\let\@bidituftefloat@orig@endfloat\end@float +\newlength{\@bidituftefloat@caption@vertical@offset} +\setlength{\@bidituftefloat@caption@vertical@offset}{0pt} +\newcommand{\@bidituftefloat@stored@shortcaption}{} +\newcommand{\@bidituftefloat@stored@caption}{} +\newcommand{\@bidituftefloat@stored@label}{} +\long\def\@bidituftefloat@caption[#1][#2]#3{% + \ifthenelse{\isempty{#1}}% + {\gdef\@bidituftefloat@stored@shortcaption{#3}}% + {\gdef\@bidituftefloat@stored@shortcaption{#1}}% + \gsetlength{\@bidituftefloat@caption@vertical@offset}{-#2}% we want a positive offset to lower captions + \gdef\@bidituftefloat@stored@caption{#3}% +} +\newcommand{\@bidituftefloat@label}[1]{% + \gdef\@bidituftefloat@stored@label{#1}% +} +\newcommand{\@bidituftefloat@fps}{} +\newboolean{@bidituftefloat@float@star} +\newlength{\@bidituftefloat@float@contents@width} +\newenvironment{@bidituftefloat@float}[3][htbp]% + {% 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}}% + % 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]}}% + % 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]}% + \ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}% + {\renewcommand{\floatalignment}{b}\@bidituftefloat@float@debug{Presumed position: [bottom]}}% + {\renewcommand{\floatalignment}{t}\@bidituftefloat@float@debug{Presumed position: [top]}}% + % Capture the contents of the \caption and \label commands to use later + \global\let\@bidituftefloat@orig@caption\caption% + \global\let\@bidituftefloat@orig@label\label% + \renewcommand{\caption}{\optparams{\@bidituftefloat@caption}{[][0pt]}}% + \renewcommand{\label}[1]{\@bidituftefloat@label{##1}}% + % Handle subfigure package compatibility + \ifthenelse{\boolean{@bidituftefloat@packages@subfigure}}{% + % don't move the label while inside a \subfigure or \subtable command + \global\let\label\@bidituftefloat@orig@label% + }{}% subfigure package is not loaded + \@bidituftefloat@orig@float{#2}[#1]% + \ifthenelse{\boolean{@bidituftefloat@float@star}}% + {\setlength{\@bidituftefloat@float@contents@width}{\@bidituftefloat@fullwidth}}% + {\setlength{\@bidituftefloat@float@contents@width}{\textwidth}}% + \begin{lrbox}{\@bidituftefloat@figure@box}% + \begin{minipage}[\floatalignment]{\@bidituftefloat@float@contents@width}\hbox{}% + }{% end @bidituftefloat@float + \par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes + \end{minipage}% + \end{lrbox}% + % build the caption box + \begin{lrbox}{\@bidituftefloat@caption@box}% + \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}% + \ifthenelse{\NOT\equal{\@bidituftefloat@stored@caption}{}}{\@bidituftefloat@orig@caption[\@bidituftefloat@stored@shortcaption]{\@bidituftefloat@stored@caption}}{}% + \ifthenelse{\NOT\equal{\@bidituftefloat@stored@label}{}}{\@bidituftefloat@orig@label{\@bidituftefloat@stored@label}}{}% + \par\vspace{-\prevdepth}%% TODO: DOUBLE-CHECK FOR SAFETY + \end{minipage}% + \end{lrbox}% + % now typeset the stored boxes + \begin{fullwidth}% + \begin{minipage}[\floatalignment]{\linewidth}% + \ifthenelse{\boolean{@bidituftefloat@float@star}}% + {\@bidituftefloat@float@fullwidth[\@bidituftefloat@caption@vertical@offset]{\@bidituftefloat@figure@box}{\@bidituftefloat@caption@box}}% + {\@bidituftefloat@float@textwidth[\@bidituftefloat@caption@vertical@offset]{\@bidituftefloat@figure@box}{\@bidituftefloat@caption@box}}% + \end{minipage}% + \end{fullwidth}% + \@bidituftefloat@orig@endfloat% end original LaTeX float environment + % output debug info + \ifthenelse{\boolean{@bidituftefloat@debug}}{% + \typeout{^^J^^J----------- bidituftefloat package float information ----------}% + \ifthenelse{\equal{\@bidituftefloat@stored@label}{}}% + {\typeout{Warning: Float unlabeled!}}% + {\typeout{Float label: [\@bidituftefloat@stored@label]}}% + \typeout{Page number: [\thepage]}% + \def\MessageBreak{^^J}% + \typeout{\@bidituftefloat@float@debug@info}% + \ifthenelse{\boolean{@bidituftefloat@symmetric}}% + {\typeout{Symmetric: [true]}}% + {\typeout{Symmetric: [false]}}% + \typeout{----------------------------------------------------^^J^^J}% + }{}% + % reset commands and temp boxes and captions + \gdef\@bidituftefloat@float@debug@info{}% + \let\caption\@bidituftefloat@orig@caption% + \let\label\@bidituftefloat@orig@label% + \begin{lrbox}{\@bidituftefloat@figure@box}\hbox{}\end{lrbox}% + \begin{lrbox}{\@bidituftefloat@caption@box}\hbox{}\end{lrbox}% + \gdef\@bidituftefloat@stored@shortcaption{}% + \gdef\@bidituftefloat@stored@caption{}% + \gdef\@bidituftefloat@stored@label{}% + \gsetlength{\@bidituftefloat@caption@vertical@offset}{0pt}% reset caption offset + } +\newcommand{\@bidituftefloat@float@textwidth}[3][0pt]{% + \ifthenelse{\NOT\boolean{@bidituftefloat@symmetric}\OR\boolean{@bidituftefloat@float@recto}}{% + % asymmetric or page is odd, so caption is on the right + \hbox{% + \usebox{#2}% + \hspace{\marginparsep}% + \smash{\raisebox{#1}{\usebox{#3}}}% + } + \@bidituftefloat@float@debug{Caption position: [right]}% + }{% symmetric pages and page is even, so caption is on the left + \hbox{% + \smash{\raisebox{#1}{\usebox{#3}}}% + \hspace{\marginparsep}% + \usebox{#2}% + } + \@bidituftefloat@float@debug{Caption position: [left]}% + }% +} +\newcommand{\@bidituftefloat@float@fullwidth}[3][0pt]{% + \ifthenelse{\equal{\floatalignment}{b}}% + {% place caption above figure + \ifthenelse{\NOT\boolean{@bidituftefloat@symmetric}\OR\boolean{@bidituftefloat@float@recto}}% + {\hfill\smash{\raisebox{#1}{\usebox{#3}}}\par\usebox{#2}\@bidituftefloat@float@debug{Caption position: [above right]}}% caption on the right + {\smash{\raisebox{#1}{\usebox{#3}}}\hfill\par\usebox{#2}\@bidituftefloat@float@debug{Caption position: [above left]}}% caption on the left + }{% place caption below figure + \ifthenelse{\NOT\boolean{@bidituftefloat@symmetric}\OR\boolean{@bidituftefloat@float@recto}}% + {\usebox{#2}\par\hfill\smash{\raisebox{#1}{\usebox{#3}}}\@bidituftefloat@float@debug{Caption position: [below right]}}% caption on the right + {\usebox{#2}\par\smash{\raisebox{#1}{\usebox{#3}}}\hfill\@bidituftefloat@float@debug{Caption position: [below left]}}% caption on the left + }% +} +\renewenvironment{figure}[1][htbp]% + {\ifvmode\else\unskip\fi\begin{@bidituftefloat@float}[#1]{figure}{}} + {\end{@bidituftefloat@float}} +\renewenvironment{table}[1][htbp] + {\ifvmode\else\unskip\fi\begin{@bidituftefloat@float}[#1]{table}{}} + {\end{@bidituftefloat@float}} +\renewenvironment{figure*}[1][htbp]% + {\ifvmode\else\unskip\fi\begin{@bidituftefloat@float}[#1]{figure}{star}} + {\end{@bidituftefloat@float}} +\renewenvironment{table*}[1][htbp]% + {\ifvmode\else\unskip\fi\begin{@bidituftefloat@float}[#1]{table}{star}} + {\end{@bidituftefloat@float}} +\newenvironment{fullwidth} + {\ifthenelse{\boolean{@bidituftefloat@symmetric}}% + {\ifthenelse{\boolean{@bidituftefloat@changepage}}{\begin{adjustwidth*}{}{-\@bidituftefloat@overhang}}{\begin{adjustwidth}[]{}{-\@bidituftefloat@overhang}}}% + {\begin{adjustwidth}{}{-\@bidituftefloat@overhang}}% + }% + {\ifthenelse{\boolean{@bidituftefloat@symmetric}}% + {\ifthenelse{\boolean{@bidituftefloat@changepage}}{\end{adjustwidth*}}{\end{adjustwidth}}}% + {\end{adjustwidth}}% + } +\long\def\@caption#1[#2]#3{% + \par% + \addcontentsline{\csname ext@#1\endcsname}{#1}% + {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% + \begingroup% + \@parboxrestore% + \if@minipage% + \@setminipage% + \fi% + \@bidituftefloat@caption@font\@bidituftefloat@caption@justification% + \noindent\csname fnum@#1\endcsname: \ignorespaces#3\par% + %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par + \endgroup} +%% +% Turns newlines into spaces. Based on code from the `titlesec' package. +\DeclareRobustCommand{\@biditufteheading@newlinetospace}{% + \@ifstar{\@biditufteheading@newlinetospace@i}{\@biditufteheading@newlinetospace@i}% +} +\def\@biditufteheading@newlinetospace@i{% + \ifdim\lastskip>\z@\else\space\fi + \ignorespaces% +} +\DeclareRobustCommand{\newlinetospace}[1]{% + \let\@biditufteheading@orig@cr\\% save the original meaning of \\ + \def\\{\@biditufteheading@newlinetospace}% turn \\ and \\* into \space + \let\newline\\% turn \newline into \space + #1% + \let\\\@biditufteheading@orig@cr% revert to original meaning of \\ +} +\RequirePackage{fancyhdr} +\pagestyle{fancy} +\AtBeginDocument{% + \ifthenelse{\boolean{@bidituftefloat@symmetric}} + {\fancyhfoffset[LE,RO]{\@bidituftefloat@overhang}} + {\fancyhfoffset[RE,RO]{\@bidituftefloat@overhang}} +} +% The running heads/feet don't have rules +\renewcommand{\headrulewidth}{0pt} +\renewcommand{\footrulewidth}{0pt} +% The 'fancy' page style is the default style for all pages. +\fancyhf{} % clear header and footer fields + \ifthenelse{\boolean{@bidituftefloat@symmetric}} + {\fancyhead[LE]{\thepage\quad\textsl{\newlinetospace{\plainauthor}}}% + \fancyhead[RO]{\textsl{\newlinetospace{\plaintitle}}\quad\thepage}}% + {\fancyhead[RE,RO]{\textsl{\newlinetospace{\plaintitle}}\quad\thepage}}% +% The `plain' page style is used on chapter opening pages. +% In Tufte's /Beautiful Evidence/ he never puts page numbers at the +% bottom of pages -- the folios are unexpressed. +\fancypagestyle{plain}{ + \fancyhf{} % clear header and footer fields + % Uncomment the following five lines of code if you want the opening page + % of the chapter to express the folio in the lower outside corner. + % \ifthenelse{\boolean{@bidituftefloat@symmetric}} + % {\fancyfoot[LE,RO]{\thepage}} + % {\fancyfoot[RE,RO]{\thepage}} +} +% The `empty' page style suppresses all headers and footers. +% It's used on title pages and `intentionally blank' pages. +\fancypagestyle{empty}{ + \fancyhf{} % clear header and footer fields +} +\def\morefloats{% provides a total of 52 floats + \ifthenelse{\isundefined{\bx@S}}{% + \bidituftefloatDebugInfoNL{Adding 34 more float slots.} + \newinsert\bx@S + \newinsert\bx@T + \newinsert\bx@U + \newinsert\bx@V + \newinsert\bx@W + \newinsert\bx@X + \newinsert\bx@Y + \newinsert\bx@Z + \newinsert\bx@a + \newinsert\bx@b + \newinsert\bx@c + \newinsert\bx@d + \newinsert\bx@e + \newinsert\bx@f + \newinsert\bx@g + \newinsert\bx@h + \newinsert\bx@i + \newinsert\bx@j + \newinsert\bx@k + \newinsert\bx@l + \newinsert\bx@m + \newinsert\bx@n + \newinsert\bx@o + \newinsert\bx@p + \newinsert\bx@q + \newinsert\bx@r + \newinsert\bx@s + \newinsert\bx@t + \newinsert\bx@u + \newinsert\bx@v + \newinsert\bx@w + \newinsert\bx@x + \newinsert\bx@y + \newinsert\bx@z + \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E + \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J + \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N + \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R + \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V + \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z + \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e + \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j + \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n + \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r + \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v + \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z}% + }{% we've already added another 34 floats, so we'll add 26 more, but that's it! + \ifthenelse{\isundefined{\bx@AA}}{% + \bidituftefloatDebugInfoNL{Adding 26 more float slots.} + \newinsert\bx@AA + \newinsert\bx@BB + \newinsert\bx@CC + \newinsert\bx@DD + \newinsert\bx@EE + \newinsert\bx@FF + \newinsert\bx@GG + \newinsert\bx@HH + \newinsert\bx@II + \newinsert\bx@JJ + \newinsert\bx@KK + \newinsert\bx@LL + \newinsert\bx@MM + \newinsert\bx@NN + \newinsert\bx@OO + \newinsert\bx@PP + \newinsert\bx@QQ + \newinsert\bx@RR + \newinsert\bx@SS + \newinsert\bx@TT + \newinsert\bx@UU + \newinsert\bx@VV + \newinsert\bx@WW + \newinsert\bx@XX + \newinsert\bx@YY + \newinsert\bx@ZZ + \gdef\@freelist{\@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E + \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J + \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N + \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R + \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V + \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z + \@elt\bx@a\@elt\bx@b\@elt\bx@c\@elt\bx@d\@elt\bx@e + \@elt\bx@f\@elt\bx@g\@elt\bx@h\@elt\bx@i\@elt\bx@j + \@elt\bx@k\@elt\bx@l\@elt\bx@m\@elt\bx@n + \@elt\bx@o\@elt\bx@p\@elt\bx@q\@elt\bx@r + \@elt\bx@s\@elt\bx@t\@elt\bx@u\@elt\bx@v + \@elt\bx@w\@elt\bx@x\@elt\bx@y\@elt\bx@z + \@elt\bx@AA\@elt\bx@BB\@elt\bx@CC\@elt\bx@DD\@elt\bx@EE + \@elt\bx@FF\@elt\bx@GG\@elt\bx@HH\@elt\bx@II\@elt\bx@JJ + \@elt\bx@KK\@elt\bx@LL\@elt\bx@MM\@elt\bx@NN + \@elt\bx@OO\@elt\bx@PP\@elt\bx@QQ\@elt\bx@RR + \@elt\bx@SS\@elt\bx@TT\@elt\bx@UU\@elt\bx@VV + \@elt\bx@WW\@elt\bx@XX\@elt\bx@YY\@elt\bx@ZZ}% + }{% + \bidituftefloatError{You may only call \string\morefloats\space twice. See the\MessageBreak bidituftefloat package documentation for other workarounds} + {There are already 78 float slots allocated. Try using \string\FloatBarrier\space or\MessageBreak \string\clearpage\space to place some floats before creating more.} + }% + }% +} +\newboolean{@bidituftefloat@packages@subfigure} +\setboolean{@bidituftefloat@packages@subfigure}{false} +\AtBeginDocument{% + \@ifpackageloaded{subfigure} + {\gsetboolean{@bidituftefloat@packages@subfigure}{true}} + {\gsetboolean{@bidituftefloat@packages@subfigure}{false}}% +} +\AtBeginDocument{% + \@ifpackageloaded{float}{% + % Save the redefined float environment (instead of the LaTeX float environment) + \let\@bidituftefloat@orig@float\@float + \let\@bidituftefloat@orig@endfloat\end@float + + % Define Tuftian float styles (with the caption in the margin) + \newcommand{\floatc@bidituftefloatplain}[2]{% + \begin{lrbox}{\@bidituftefloat@caption@box}% + \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}% + \@bidituftefloat@caption@font{\@fs@cfont #1:} #2\par% + \end{minipage}% + \end{lrbox}% + \smash{\hspace{\@bidituftefloat@caption@fill}\usebox{\@bidituftefloat@caption@box}}% + } + \newcommand{\fs@bidituftefloatplain}{% + \def\@fs@cfont{\@bidituftefloat@caption@font}% + \let\@fs@capt\floatc@bidituftefloatplain% + \def\@fs@pre{}% + \def\@fs@post{}% + \def\@fs@mid{}% + \let\@fs@iftopcapt\iftrue% + } + \let\fs@bidituftefloatplaintop=\fs@bidituftefloatplain + \let\floatc@bidituftefloatplaintop=\floatc@bidituftefloatplain + \newcommand\floatc@bidituftefloatruled[2]{% + {\@fs@cfont #1} #2\par% + } + \newcommand\fs@bidituftefloatruled{% + \def\@fs@cfont{\@bidituftefloat@caption@font}% + \let\@fs@capt\floatc@bidituftefloatplain% + \def\@fs@pre{\hrule height.8pt depth0pt width\textwidth \kern2pt}% + \def\@fs@post{\kern2pt\hrule width\textwidth\relax}% + \def\@fs@mid{}% + \let\@fs@iftopcapt\iftrue% + } + \newcommand\fs@bidituftefloatboxed{% + \def\@fs@cfont{}% + \let\@fs@capt\floatc@bidituftefloatplain% + \def\@fs@pre{% + \setbox\@currbox\vbox{\hbadness10000 + \moveleft3.4pt\vbox{\advance\hsize by6.8pt + \hrule \hbox to\hsize{\vrule\kern3pt + \vbox{\kern3pt\box\@currbox\kern3pt}\kern3pt\vrule}\hrule}} + }% + \def\@fs@mid{\kern2pt}% + \def\@fs@post{}% + \let\@fs@iftopcapt\iftrue% + } + }{% + % Nothing to do + } +} +\AtBeginDocument{% + \@ifpackageloaded{algorithm}{% + % Set the float style to the Tuftian version + \ifthenelse{\equal{\ALG@floatstyle}{plain}\OR\equal{\ALG@floatstyle}{ruled}\OR\equal{\ALG@floatstyle}{boxed}}{% + \bidituftefloatInfoNL{Switching algorithm float style from \ALG@floatstyle\MessageBreak to bidituftefloat\ALG@floatstyle}% + \floatstyle{bidituftefloat\ALG@floatstyle}% + \restylefloat{algorithm}% + }{}% + }{% + % Nothing to do + } +} +\PassOptionsToPackage{caption=false}{subfig} +% \end{macrocode} +% \iffalse +%</bidituftefloat.sty> +%<*bidituftesidenote.sty> +%\fi +% \subsection{\textsf{bidituftesidenote.sty}} +% \begin{macrocode} +\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}% +} +%% +% Globally sets the length +\@ifundefined{gsetlength}{% +\newcommand*{\gsetlength}[2]{% + \setlength{#1}{#2}% + \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.) +% Executing \@bidituftesidenote@trim@spaces\xyzzy will result in the contents of \xyzzy +% being trimmed of leading and trailing white space. +\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}% +} +% \trimb removes a trailing space if present, then calls \@bidituftesidenote@trim@c to +% clean up any leftover bizarre Qs, and trim a leading space. In +% order for \trimc to work properly we need to put back a Q first. +\def\@bidituftesidenote@trim@b#1 Q{\@bidituftesidenote@trim@c#1Q} +% Execute \vfuzz assignment to remove leading space; the \noexpand +% will now prevent unwanted expansion of a macro or other expandable +% token at the beginning of the trimmed text. The \endgroup will feed +% in the \aftergroup tokens after the \vfuzz assignment is completed. +\def\@bidituftesidenote@trim@c#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1} +\catcode`\Q=11 +%% +% Citations should go in the margin as sidenotes + +\RequirePackage{natbib} +\RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment +% Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style +\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 +%% +% Normal \cite behavior +\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}% + }% + }% +} +%% +% Macros for holding the list of cite keys until after the \sidenote +\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}% + }% + }% +} +%% +% \cite behavior when executed within a sidenote +\newcommand{\@bidituftesidenote@sidenote@citations}{}% contains list of \cites in sidenote +\newcommand{\@bidituftesidenote@infootnote@cite}[1]{% + \@bidituftesidenote@add@citation{#1} +} +%% +% Set the default \cite style. This is set and reset by the \sidenote command. +\let\cite\@bidituftesidenote@normal@cite +%% +% Transform existing \footnotes into \sidenotes +% Sidenote: ``Where God meant footnotes to go.'' ---bidituftesidenote +\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} +% Override footmisc's definition to set the sidenote marks (numbers) inside the +% sidenote's text block. +\hopatch@AfterPackage{bidi}{\long\def\@makefntext#1{\@textsuperscript{\@bidituftesidenote@sidenote@font\tiny\@thefnmark}\,\footnotelayout#1}} +% Set the in-text footnote mark in the same typeface as the body text itself. +\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% + }% +}% +} +% +% Define \sidenote command. Can handle \cite. +\newlength{\@bidituftesidenote@sidenote@vertical@offset} +\setlength{\@bidituftesidenote@sidenote@vertical@offset}{0pt} +% #1 = footnote num, #2 = vertical offset, #3 = footnote text +\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]}}% +} +%% +% Sidenote without the footnote mark +\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 +} +% \end{macrocode} +% \iffalse +%</bidituftesidenote.sty> +%<*bidituftetoc.sty> +%\fi +% \subsection{\textsf{bidituftetoc.sty}} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bidituftetoc}[2011/06/17 v0.1 +bidi implementation of tufte toc] +\RequirePackage{titlesec,titletoc,xifthen,hopatch} +\newcommand{\@bidituftetoc@pkgname}{bidituftetoc} +\newcommand{\bidituftetocError}[2]{\PackageError{\@bidituftetoc@pkgname}{#1}{#2}} +%% +% Turn off section numbering +\setcounter{secnumdepth}{-1} +\newboolean{@bidituftetoc@toc} +\setboolean{@bidituftetoc@toc}{true} +\DeclareOption{notoc}{\setboolean{@bidituftetoc@toc}{false}} +\DeclareOption{toc}{\setboolean{@bidituftetoc@toc}{true}} +\ProcessOptions +%% +% Make Tuftian-style section headings and TOC formatting +\hopatch@AfterPackage{bidi}{% +\titleformat{\chapter}% + [display]% shape + {\relax\ifthenelse{\NOT\boolean{@bidituftefloat@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text + {\itshape\huge\thechapter}% label + {0pt}% horizontal separation between label and title body + {\huge\rmfamily\itshape}% before the title body + [\ifthenelse{\NOT\boolean{@bidituftefloat@symmetric}}{\end{fullwidth}}{}]% after the title body +\titleformat{\section}% + [hang]% shape + {\normalfont\Large\itshape}% format applied to label+text + {\thesection}% label + {1em}% horizontal separation between label and title body + {}% before the title body + []% after the title body +\titleformat{\subsection}% + [hang]% shape + {\normalfont\large\itshape}% format applied to label+text + {\thesubsection}% label + {1em}% horizontal separation between label and title body + {}% before the title body + []% after the title body +\titleformat{\paragraph}% + [runin]% shape + {\normalfont\itshape}% format applied to label+text + {\theparagraph}% label + {1em}% horizontal separation between label and title body + {}% before the title body + []% after the title body +\titlespacing*{\chapter}{0pt}{50pt}{40pt} +\titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex} +\titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus.2ex} +} +% Subsubsection and following section headings shouldn't be used. +% See Bringhurst's _The Elements of Typography_, section 4.2.2. +\renewcommand\subsubsection{% + \bidituftetocError{\noexpand\subsubsection is undefined by this class.% + \MessageBreak See Robert Bringhurst's _The Elements of + \MessageBreak Typographic Style_, section 4.2.2. + \MessageBreak \noexpand\subsubsection was used} + {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as + \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many + \MessageBreak related threads on Ask E.T. at http://www.edwardbidituftetoc.com/.} +} +\renewcommand\subparagraph{% + \bidituftetocError{\noexpand\subparagraph is undefined by this class.% + \MessageBreak See Robert Bringhurst's _The Elements of + \MessageBreak Typographic Style_, section 4.2.2. + \MessageBreak \noexpand\subparagraph was used} + {From Bringhurst's _The Elements of Typographic Style_, section 4.2.2: Use as + \MessageBreak many levels of headings as you need, no more and no fewer. Also see the many + \MessageBreak related threads on Ask E.T. at http://www.edwardbidituftetoc.com/.} +} +% Formatting for main TOC (printed in front matter) +% {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after] +\ifthenelse{\boolean{@bidituftetoc@toc}}{% + \hopatch@AfterPackage{bidi}{% + \titlecontents{part}% FIXME + [0em] % distance from left margin + {\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry) + {\contentslabel{2em}} % before w/label (label = ``II'') + {} % before w/o label + {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) + [\end{fullwidth}] % after + \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 + \titlecontents{section}% FIXME + [0em] % distance from left margin + {\vspace{0\baselineskip}\begin{fullwidth}\Large\rmfamily\itshape} % above (global formatting of entry) + {\hspace*{2em}\contentslabel{2em}} % before w/label (label = ``2.6'') + {\hspace*{2em}} % before w/o label + {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) + [\end{fullwidth}] % after + \titlecontents{subsection}% FIXME + [0em] % distance from left margin + {\vspace{0\baselineskip}\begin{fullwidth}\large\rmfamily\itshape} % above (global formatting of entry) + {\hspace*{4em}\contentslabel{4em}} % before w/label (label = ``2.6.1'') + {\hspace*{4em}} % before w/o label + {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) + [\end{fullwidth}] % after + \titlecontents{paragraph}% FIXME + [0em] % distance from left margin + {\vspace{0\baselineskip}\begin{fullwidth}\normalsize\rmfamily\itshape} % above (global formatting of entry) + {\hspace*{6em}\contentslabel{2em}} % before w/label (label = ``2.6.0.0.1'') + {\hspace*{6em}} % before w/o label + {\rmfamily\upshape\qquad\thecontentspage} % filler + page (leaders and page num) + [\end{fullwidth}] % after +}% +}{} +%% +% Format lists of figures/tables +\renewcommand\listoffigures{% + \@ifundefined{chapter}% + {\section*{\listfigurename}}% + {\chapter*{\listfigurename}}% +% \begin{fullwidth}% + \@starttoc{lof}% +% \end{fullwidth}% +} +\renewcommand\listoftables{% + \@ifundefined{chapter}% + {\section*{\listtablename}}% + {\chapter*{\listtablename}}% +% \begin{fullwidth}% + \@starttoc{lot}% +% \end{fullwidth}% +} +\newcommand{\@bidituftetoc@lof@line}[2]{% + % #1 is the figure/table number and its caption text + % #2 is the page number on which the figure/table appears + \leftskip 0.0em + \rightskip 0em + \parfillskip 0em plus 1fil + \parindent 0.0em + \@afterindenttrue + \interlinepenalty\@M + \leavevmode + \@tempdima 2.0em + \if@RTL\advance\rightskip\@tempdima\else\advance\leftskip\@tempdima\fi + \null\nobreak\hskip -\if@RTL\rightskip\else\leftskip\fi + {#1}\nobreak\qquad\nobreak#2% + \par% +} +\renewcommand*\l@figure{\@bidituftetoc@lof@line} +\let\l@table\l@figure +% \end{macrocode} +% \iffalse +%</bidituftetoc.sty> +%<*bidituftegeneralstructure.sty> +%\fi +% \subsection{\textsf{bidituftegeneralstructure.sty}} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bidituftegeneralstructure}[2011/06/18 v0.1 +bidi implementation of tufte general structure] +\renewcommand\small{% + \@setfontsize\small\@ixpt{12}% + \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@ + \abovedisplayshortskip \z@ \@plus2\p@ + \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@ + \def\@listi{\leftmargin\leftmargini + \topsep 4\p@ \@plus2\p@ \@minus2\p@ + \parsep 2\p@ \@plus\p@ \@minus\p@ + \itemsep \parsep}% + \belowdisplayskip \abovedisplayskip +} +\renewcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt} +\renewcommand\tiny{\@setfontsize\tiny\@vpt\@vipt} +\renewcommand\large{\@setfontsize\large\@xipt{15}} +\renewcommand\Large{\@setfontsize\Large\@xiipt{16}} +\renewcommand\LARGE{\@setfontsize\LARGE\@xivpt{18}} +\renewcommand\huge{\@setfontsize\huge\@xxpt{30}} +\renewcommand\Huge{\@setfontsize\Huge{24}{36}} +\setlength\leftmargini {1pc} +\setlength\leftmarginii {1pc} +\setlength\leftmarginiii {1pc} +\setlength\leftmarginiv {1pc} +\setlength\leftmarginv {1pc} +\setlength\leftmarginvi {1pc} +\setlength\labelsep {.5pc} +\setlength\labelwidth {\leftmargini} +\addtolength\labelwidth{-\labelsep} +\setlength{\parindent}{1.0pc}% +\setlength{\parskip}{0pt}% +\RequirePackage{ragged2e} +\setlength{\RaggedRightRightskip}{\z@ plus 0.08\hsize} +% Paragraph indentation and separation for normal text +\newcommand{\@bidituftegeneralstructure@reset@par}{% + \setlength{\RaggedRightParindent}{1.0pc}% + \setlength{\JustifyingParindent}{1.0pc}% + \setlength{\parindent}{1pc}% + \setlength{\parskip}{0pt}% +} +\@bidituftegeneralstructure@reset@par +% Require paralist package for tighter lists +\RequirePackage{paralist} +% Add rightmargin to compactenum +\def\@compactenum@{% + \expandafter\list\csname label\@enumctr\endcsname{% + \usecounter{\@enumctr}% + \rightmargin=2em% added this + \parsep\plparsep + \itemsep\plitemsep + \topsep\pltopsep + \partopsep\plpartopsep + \def\makelabel##1{\hss\llap{##1}}}} +%% +% An environment for paragraph-style section +\providecommand\newthought[1]{% + \addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}% + \noindent\textbf{#1}% +} +%% +% Redefine the display environments (quote, quotation, etc.) +\renewenvironment{verse} + {\let\\\@centercr + \list{}{\itemsep \z@ + \itemindent -1pc% + \listparindent\itemindent + \rightmargin \leftmargin + \advance\leftmargin 1pc}% + \small% + \item\relax} + {\endlist} +\renewenvironment{quotation} + {\list{}{\listparindent 1pc% + \itemindent \listparindent + \rightmargin \leftmargin + \parsep \z@ \@plus\p@}% + \small% + \item\relax\noindent\ignorespaces} + {\endlist} +\renewenvironment{quote} + {\list{}{\rightmargin\leftmargin}% + \small% + \item\relax} + {\endlist} +% Italicize description run-in headings (instead of the default bold) +\renewcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\em #1} +%% +% Redefine \bibsection to not mark the running heads. +% (Code modified from natbib.sty.) +\@ifundefined{chapter}% + {\renewcommand\bibsection{\section*{\refname}}} + {\@ifundefined{NAT@sectionbib}% + {\renewcommand\bibsection{\chapter{\bibname}}} + {\renewcommand\bibsection{\section*{\bibname}}}} +\RequirePackage{multicol} +\renewenvironment{theindex}{% +\@ifundefined{chapter}% + {\section*{\indexname}}% + {\chapter{\indexname}}% + \begin{fullwidth}% + \small% + \parskip0pt% + \parindent0pt% + \let\item\@idxitem% + \begin{multicols}{3}% +}{% + \end{multicols}% + \end{fullwidth}% +} +\renewcommand\@idxitem{\par\hangindent 2em} +\renewcommand\subitem{\par\hangindent 3em\hspace*{1em}} +\renewcommand\subsubitem{\par\hangindent 4em\hspace*{2em}} +\renewcommand\indexspace{\par\addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}\relax}% +\newcommand{\lettergroup}[1]{}% swallow the letter heading in the index +% \end{macrocode} +% \iffalse +%</bidituftegeneralstructure.sty> +%<*bidituftehyperref.sty> +%\fi +% \subsection{\textsf{bidituftehyperref.sty}} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bidituftehyperref}[2011/06/18 v0.1 +bidi implementation of tufte hyperref] +%% +% Color +\RequirePackage[usenames,dvipsnames,svgnames]{xcolor}% +\newboolean{@bidituftehyperref@loadhyper} +\setboolean{@bidituftehyperref@loadhyper}{true} +\DeclareOption{hyper}{\setboolean{@bidituftehyperref@loadhyper}{true}} +\DeclareOption{nohyper}{\setboolean{@bidituftehyperref@loadhyper}{false}} +\ProcessOptions +%% Loads the hyperref package and sets some default options. +\newcommand{\bidituftehyperrefLoadHyperref}{% +\RequirePackage[hyperfootnotes=false,colorlinks=true]{hyperref} + \hypersetup{% + bookmarksdepth = section, + citecolor = DarkGreen, + linkcolor = DarkBlue, +% pagecolor = DarkBlue, + urlcolor = DarkGreen, + }% +} +\ifthenelse{\boolean{@bidituftehyperref@loadhyper}}{% + \bidituftehyperrefLoadHyperref% +}{% hyperfootnotes override our modifications to the \footnote* and \@footnote* commands. + \PassOptionsToPackage{hyperfootnotes=false}{hyperref} +} +% \end{macrocode} +% \iffalse +%</bidituftehyperref.sty> +%<*bidituftetitle.sty> +%\fi +% \subsection{\textsf{bidituftetitle.sty}} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{bidituftetitle}[2011/06/18 v0.1 +bidi implementation of tufte title] +\RequirePackage{etoolbox} +%% +% `titlepage' option -- creates a full title page with \maketitle +\newboolean{@bidituftetitle@titlepage} +\DeclareOption{titlepage}{\setboolean{@bidituftetitle@titlepage}{true}} +\DeclareOption{notitlepage}{\setboolean{@bidituftetitle@titlepage}{false}} +% Default `book' and `handout' options +\@ifclassloaded{book}{% +\ExecuteOptions{titlepage}}{% +\@ifclassloaded{article}{% +\ExecuteOptions{notitlepage}}% +{}} +\ProcessOptions +%% +% Modified \title, \author, and \date commands. These store the +% (footnote-less) values in \plaintitle, \plainauthor, and \thedate, respectively. +\newcommand{\plaintitle}{}% plain-text-only title +\newcommand{\plainauthor}{}% plain-text-only author +\newcommand{\plainpublisher}{}% plain-text-only publisher +\newcommand{\thanklesstitle}{}% full title text minus \thanks{} +\newcommand{\thanklessauthor}{}% full author text minus \thanks{} +\newcommand{\thanklesspublisher}{}% full publisher minus \thanks{} +\newcommand{\@publisher}{}% full publisher with \thanks{} +\newcommand{\thedate}{\today} +\hopatch@AfterPackage{bidi}{% +\renewcommand{\thanks}[1]{\footnote{#1}} +\renewcommand{\LTRthanks}[1]{\LTRfootnote{#1}} +\renewcommand{\RTLthanks}[1]{\RTLfootnote{#1}} +} +\renewcommand{\title}[2][]{% + \gdef\@title{#2}% + \begingroup% + % TODO store contents of \thanks command + \renewcommand{\thanks}[1]{}% swallow \thanks contents + \renewcommand{\LTRthanks}[1]{}% swallow \LTRthanks contents + \renewcommand{\RTLthanks}[1]{}% swallow \RTLthanks contents + \protected@xdef\thanklesstitle{#2}% + \endgroup% + \ifthenelse{\isempty{#1}}% + {\renewcommand{\plaintitle}{\thanklesstitle}}% use thankless title + {\renewcommand{\plaintitle}{#1}}% use provided plain-text title + \@ifundefined{hypersetup}% + {}% hyperref is not loaded; do nothing + {\hypersetup{pdftitle={\plaintitle}}}% set the PDF metadata title +} +\let\@author\@empty% suppress default latex.ltx ``no author'' warning +\renewcommand{\author}[2][]{% + \ifthenelse{\isempty{#2}}{}{\gdef\@author{#2}}% + \begingroup% + % TODO store contents of \thanks command + \renewcommand{\thanks}[1]{}% swallow \thanks contents + \renewcommand{\LTRthanks}[1]{}% swallow \LTRthanks contents + \renewcommand{\RTLthanks}[1]{}% swallow \RTLthanks contents + \protected@xdef\thanklessauthor{#2}% + \endgroup% + \ifthenelse{\isempty{#1}}% + {\renewcommand{\plainauthor}{\thanklessauthor}}% use thankless author + {\renewcommand{\plainauthor}{#1}}% use provided plain-text author + \@ifundefined{hypersetup}% + {}% hyperref is not loaded; do nothing + {\hypersetup{pdfauthor={\plainauthor}}}% set the PDF metadata author +} +\renewcommand{\date}[1]{% + \gdef\@date{#1}% + \begingroup% + % TODO store contents of \thanks command + \renewcommand{\thanks}[1]{}% swallow \thanks contents + \renewcommand{\LTRthanks}[1]{}% swallow \LTRthanks contents + \renewcommand{\RTLthanks}[1]{}% swallow \RTLthanks contents + \protected@xdef\thedate{#1}% + \endgroup% +} +%% +% Provides a \publisher command to set the publisher +\newcommand{\publisher}[2][]{% + \gdef\@publisher{#2}% + \begingroup% + \renewcommand{\thanks}[1]{}% swallow \thanks contents + \renewcommand{\LTRthanks}[1]{}% swallow \LTRthanks contents + \renewcommand{\RTLthanks}[1]{}% swallow \RTLthanks contents + \protected@xdef\thanklesspublisher{#2}% + \endgroup% + \ifthenelse{\isempty{#1}} + {\renewcommand{\plainpublisher}{\thanklesspublisher}}% use thankless publisher + {\renewcommand{\plainpublisher}{#1}}% use provided plain-text publisher +} +%% +% Produces a full title page +\newcommand{\maketitlepage}[0]{% + \cleardoublepage% + {% + \bfseries% + \begin{fullwidth}% + \fontsize{18}{20}\selectfont\par\noindent\thanklessauthor% + \vspace{11.5pc}% + \fontsize{36}{40}\selectfont\par\noindent\thanklesstitle% + \vfill% + \fontsize{14}{16}\selectfont\par\noindent\thanklesspublisher% + \end{fullwidth}% + } + \thispagestyle{empty}% + \clearpage% +} +%% +% Title block +\AfterEndPreamble{% +\renewcommand{\maketitle}{% + \newpage% + \global\@topnum\z@% prevent floats from being placed at the top of the page + \begingroup% + \setlength{\parindent}{0pt}% + \setlength{\parskip}{4pt}% + \let\@@title\@empty% + \let\@@author\@empty% + \let\@@date\@empty% + \gdef\@@title{\LARGE\itshape\@title\par}% + \gdef\@@author{\Large\itshape\@author\par}% + \gdef\@@date{\Large\itshape\@date\par}% + \@@title% + \@@author% + \@@date% + \endgroup% + \thispagestyle{plain}% suppress the running head +}% +} +%% +% Title page (if the `titlepage' option was passed to the bidituftetitle-handout +% class.) +\AfterEndPreamble{% +\ifthenelse{\boolean{@bidituftetitle@titlepage}} + {\renewcommand{\maketitle}{\maketitlepage}} + {} +} +%% +% When \cleardoublepage is called, produce a blank (empty) page -- i.e., +% without headers and footers +\def\cleardoublepage{\clearpage\if@twoside\ifodd\c@page\else + \hbox{} + %\vspace*{\fill} + %\begin{center} + % This page intentionally contains only this sentence. + %\end{center} + %\vspace{\fill} + \thispagestyle{empty} + \newpage + \if@twocolumn\hbox{}\newpage\fi\fi\fi} +% \end{macrocode} +% \iffalse +%</bidituftetitle.sty> +%<*biditufte-handout.cls> +%\fi +% \subsection{\textsf{biditufte-handout.cls}} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}[1994/06/01] +\ProvidesClass{biditufte-handout}[2011/06/18 v0.1 biditufte-handout class] +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{bidituftefloat}} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{bidituftetoc}} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{bidituftehyperref}} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{bidituftetitle}} +\ProcessOptions\relax +\LoadClass{article} +\RequirePackage{bidituftefloat} +\RequirePackage{bidituftesidenote} +\RequirePackage{bidituftetoc} +\RequirePackage{bidituftegeneralstructure} +\RequirePackage{bidituftehyperref} +\RequirePackage{bidituftetitle} +\renewenvironment{abstract} + {\begin{quotation}} + {\end{quotation}} +\AtBeginDocument{% +\IfFileExists{biditufte-handout.cfg} + {\input{biditufte-handout.cfg} + \ClassInfo{biditufte-handout}{Loading biditufte-handout configuration file \@gobble}} + {}% +} +% \end{macrocode} +% \iffalse +%</biditufte-handout.cls> +%<*biditufte-book.cls> +%\fi +% \subsection{\textsf{biditufte-book.cls}} +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}[1994/06/01] +\ProvidesClass{biditufte-book}[2011/06/18 v0.1 biditufte-book class] +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{bidituftefloat}} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{bidituftetoc}} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{bidituftehyperref}} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{bidituftetitle}} +\ProcessOptions\relax +\LoadClass{book} +\RequirePackage{bidituftefloat} +\RequirePackage{bidituftesidenote} +\RequirePackage{bidituftetoc} +\RequirePackage{bidituftegeneralstructure} +\RequirePackage{bidituftehyperref} +\RequirePackage{bidituftetitle} +%% +% Set up any book-specific stuff now +%% +% The front matter in Tufte's /Beautiful Evidence/ contains everything up +% to the opening page of Chapter 1. The running heads, when they appear, +% contain only the (arabic) page number in the outside corner. +%\newif\if@mainmatter \@mainmattertrue +\renewcommand\frontmatter{% + \cleardoublepage% + \@mainmatterfalse% + \pagenumbering{arabic}% + %\pagestyle{plain}% + \fancyhf{}% + \ifthenelse{\boolean{@bidituftefloat@twoside}}% + {\fancyhead[LE,RO]{\thepage}}% + {\fancyhead[RE,RO]{\thepage}}% +} +%% +% The main matter in Tufte's /Beautiful Evidence/ doesn't restart the page +% numbering---it continues where it left off in the front matter. +\renewcommand\mainmatter{% + \cleardoublepage% + \@mainmattertrue% + \fancyhf{}% + \ifthenelse{\boolean{@bidituftefloat@twoside}}% + {\renewcommand{\chaptermark}[1]{\markboth{##1}{}}% + \fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plaintitle}}}% book title + \fancyhead[RO]{\smallcaps{\newlinetospace{\leftmark}}\quad\thepage}}% chapter title + {\fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}}% book title +} +%% +% The back matter contains appendices, indices, glossaries, endnotes, +% biliographies, list of contributors, illustration credits, etc. +\renewcommand\backmatter{% + \if@openright% + \cleardoublepage% + \else% + \clearpage% + \fi% + \@mainmatterfalse% +} +%% +% Only show the chapter titles in the table of contents +\setcounter{tocdepth}{0} +\AtBeginDocument{% +\IfFileExists{biditufte-book.cfg} + {\input{biditufte-book.cfg} + \ClassInfo{biditufte-book}{Loading biditufte-book configuration file \@gobble}} + {}% +} +% \end{macrocode} +% \iffalse +%</biditufte-book.cls> %<*bidipoem.sty> %\fi % \subsection{\textsf{bidipoem.sty}} @@ -4872,7 +6515,10 @@ Location on CTAN: /macros/latex/contrib/bidi} %\fi % \subsection{\textsf{extrafootnotefeatures.def}} % \begin{macrocode} -\ProvidesFile{extrafootnotefeatures}[2011/03/01 v0.1 bidi extra footnote features for XeTeX engine] +\ProvidesFile{extrafootnotefeatures}[2011/08/01 v0.2 bidi extra footnote features for XeTeX engine] +\newif\if@parafootRTL +\newcommand{\setRTLparagraphfootnotes}{\@parafootRTLtrue} +\newcommand{\setLTRparagraphfootnotes}{\@parafootRTLfalse} \let\m@mold@footnotetext\@footnotetext \let\m@mold@LTRfootnotetext\@LTRfootnotetext \let\m@mold@RTLfootnotetext\@RTLfootnotetext @@ -4959,11 +6605,8 @@ Location on CTAN: /macros/latex/contrib/bidi} \m@mdoextrafeetendmini \@minipagefalse \color@endgroup - \egroup - \if@RTL\endL\fi - \egroup \egroup - \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa\leavevmode}} + \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}} \newcommand{\m@make@footstart}[1]{% \@namedef{@footstart#1}{% \vskip\bigskipamount @@ -6277,7 +7920,9 @@ Location on CTAN: /macros/latex/contrib/bidi} \newcommand*{\m@minterparanoteglue}[1]{% {\foottextfont\global\m@mipn@skip=#1\relax}} \m@minterparanoteglue{1em plus.4em minus.4em} -\newcommand*{\m@mmakehboxofhboxes}{\setbox0=\hbox{}% +\newcommand*{\m@mmakehboxofhboxes}{% + \if@parafootRTL\@RTLtrue\else\@RTLfalse\fi% + \setbox0=\hbox{}% \loop \unpenalty \setbox2=\lastbox @@ -6290,11 +7935,15 @@ Location on CTAN: /macros/latex/contrib/bidi} \newcommand{\paragraphfootnotes}{% \@namedef{foottextfontv@r}{\foottextfont}% % [RS] \let\@footnotetext\@parafootnotetext + \let\@LTRfootnotetext\@paraLTRfootnotetext + \let\@RTLfootnotetext\@paraRTLfootnotetext \dimen\footinsv@r=\footinsdim \count\footinsv@r=1000\relax \m@make@para@footgroup{v@r}% \let\@footgroupv@r\@para@footgroupv@r \let\@mpfootnotetext\@mpparafootnotetext + \let\@mpLTRfootnotetext\@mpparaLTRfootnotetext + \let\@mpRTLfootnotetext\@mpparaRTLfootnotetext \m@make@mppara@footgroup{v@r}% \let\mp@footgroupv@r\@mppara@footgroupv@r {\foottextfont @@ -6302,7 +7951,29 @@ Location on CTAN: /macros/latex/contrib/bidi} \multiply\dimen0 by 1024 \divide\dimen0 by \hsize \multiply\dimen0 by \footfudgefiddle \xdef\footfudgefactor{\expandafter\strip@pt\dimen0 }}} -\newcommand{\@parafootnotetext}[1]{\insert\footinsv@r{ +\newcommand{\@parafootnotetext}[1]{\insert\footinsv@r{\@RTLfalse + \def\baselinestretch{\m@m@footnote@spacing}% + \reset@font\foottextfont + \@preamfntext + \protected@edef\@currentlabel{% + \csname p@footnote\endcsname\@thefnmark}% + \setbox0=\vbox{\hsize=\maxdimen + \color@begingroup + \noindent \@parafootfmt{\if@RTL@footnote\beginR\else\beginL\fi#1\if@RTL@footnote\endR\else\endL\fi}% + \color@endgroup}% + \m@mungebox}\m@mmf@prepare} +\newcommand{\@paraLTRfootnotetext}[1]{\insert\footinsv@r{\@RTLfalse + \def\baselinestretch{\m@m@footnote@spacing}% + \reset@font\foottextfont + \@preamfntext + \protected@edef\@currentlabel{% + \csname p@footnote\endcsname\@thefnmark}% + \setbox0=\vbox{\hsize=\maxdimen + \color@begingroup + \noindent \@parafootfmt{\beginL#1\endL}% + \color@endgroup}% + \m@mungebox}\m@mmf@prepare} +\newcommand{\@paraRTLfootnotetext}[1]{\insert\footinsv@r{\@RTLfalse \def\baselinestretch{\m@m@footnote@spacing}% \reset@font\foottextfont \@preamfntext @@ -6310,7 +7981,7 @@ Location on CTAN: /macros/latex/contrib/bidi} \csname p@footnote\endcsname\@thefnmark}% \setbox0=\vbox{\hsize=\maxdimen \color@begingroup - \noindent \@parafootfmt{#1}% + \noindent \@parafootfmt{\beginR#1\endR}% \color@endgroup}% \m@mungebox}\m@mmf@prepare} \newcommand{\@parafootfmt}[1]{% @@ -6318,7 +7989,33 @@ Location on CTAN: /macros/latex/contrib/bidi} \parfillskip=0pt \@plus 1fil {\footfootmark\strut {\foottextfont #1}\penalty-10}} \newcommand{\@mpparafootnotetext}[1]{% - \global\setbox\@mpfootinsv@r\vbox{% + \global\setbox\@mpfootinsv@r\vbox{\@RTLfalse% + \unvbox\@mpfootinsv@r + \def\baselinestretch{\m@m@footnote@spacing}% + \reset@font\foottextfont + \hsize\columnwidth \@parboxrestore + \protected@edef\@currentlabel{% + \csname p@mpfootnote\endcsname\@thefnmark}% + \setbox0=\vbox{\hsize=\maxdimen + \color@begingroup + \noindent \@parafootfmt{\if@RTL@footnote\beginR\else\beginL\fi#1\if@RTL@footnote\endR\else\endL\fi}% + \color@endgroup}% + \m@mungebox}\m@mmf@prepare} +\newcommand{\@mpparaLTRfootnotetext}[1]{% + \global\setbox\@mpfootinsv@r\vbox{\@RTLfalse% + \unvbox\@mpfootinsv@r + \def\baselinestretch{\m@m@footnote@spacing}% + \reset@font\foottextfont + \hsize\columnwidth \@parboxrestore + \protected@edef\@currentlabel{% + \csname p@mpfootnote\endcsname\@thefnmark}% + \setbox0=\vbox{\hsize=\maxdimen + \color@begingroup + \noindent \@parafootfmt{\beginL#1\endL}% + \color@endgroup}% + \m@mungebox}\m@mmf@prepare} +\newcommand{\@mpparaRTLfootnotetext}[1]{% + \global\setbox\@mpfootinsv@r\vbox{\@RTLfalse% \unvbox\@mpfootinsv@r \def\baselinestretch{\m@m@footnote@spacing}% \reset@font\foottextfont @@ -6327,7 +8024,7 @@ Location on CTAN: /macros/latex/contrib/bidi} \csname p@mpfootnote\endcsname\@thefnmark}% \setbox0=\vbox{\hsize=\maxdimen \color@begingroup - \noindent \@parafootfmt{#1}% + \noindent \@parafootfmt{\beginR#1\endR}% \color@endgroup}% \m@mungebox}\m@mmf@prepare} \newcommand{\paragraphfootstyle}[1]{% @@ -7051,7 +8748,7 @@ Location on CTAN: /macros/latex/contrib/bidi} \@pboxswfalse \setlength\@tempdima{#4}% \def\@mpargs{{#1}{#2}[#3]{#4}}% - \setbox\@tempboxa\vbox\bgroup\hbox\bgroup\if@RTL\beginL\fi\if #1t\vtop\else\vbox\fi\bgroup + \setbox\@tempboxa\vbox\bgroup \color@begingroup \hsize\@tempdima \textwidth\hsize \columnwidth\hsize @@ -7361,6 +9058,418 @@ Location on CTAN: /macros/latex/contrib/bidi} % \end{macrocode} % \iffalse %</graphicx-xetex-bidi.def> +%<*hvfloat-xetex-bidi.def> +%\fi +% \subsection{\textsf{hvfloat-xetex-bidi.def}} +% \begin{macrocode} +\ProvidesFile{hvfloat-xetex-bidi.def}[2011/06/11 v0.1 bidi adaptations for hvfloat package for XeTeX engine] +\def\do@@hvFloat[#1]#2#3{% + \def\hv@shortCap{#1} + \def\hv@longCap{#2} + \def\hv@label{#3} +%\newcommand*{\hvFloat}[5][]{% +% [#1}: keyvalues +% #2: type figure | table | ... +% #3: float contents +% [#4]: short caption +% #5: caption +% #6: label +% \setDefaults% +% \def\@tempa{#1}% +% \ifx\@tempa\empty\else\setkeys{hvSet}{#1}\fi% set options, only when not empty + \def\@tempa{90}% + \ifx\hvSet@rotAngle\@tempa + \setlength{\hvMaxCapWidth}{\textheight} + \else + \setlength{\hvMaxCapWidth}{\linewidth} + \fi +% +% First we save the object in \hvObjectBox +% + \ifx\hvSet@objectAngle\hv@Zero % rotate the object? + \savebox{\hvObjectBox}{\ifhv@useOBox\usebox{\hvOBox}\else\hv@floatObject\fi} + \else + \savebox{\hvObjectBox}{% + \rotatebox{\hvSet@objectAngle}{% + \ifhv@useOBox\usebox{\hvOBox}\else\hv@floatObject\fi}} + \fi + \setlength{\hvObjectWidth}{\wd\hvObjectBox} +% +% Now we save the caption with its defined \hvCapWidth +% + \ifx\hvSet@capWidth\hv@Width + \setlength{\hvCapWidth}{\hvObjectWidth} + \else + \ifx\hvSet@capWidth\hv@Height + \setlength{\hvCapWidth}{\ht\hvObjectBox} + \else + \setlength{\hvCapWidth}{\hvObjectWidth} + \ifx\hvSet@capPos\hv@Left + \addtolength{\hvMaxCapWidth}{-\hvObjectWidth} + \fi + \ifx\hvSet@capPos\hv@Right + \addtolength{\hvMaxCapWidth}{-\hvObjectWidth} + \fi + \ifdim\hvSet@capWidth\columnwidth<\hvMaxCapWidth + \setlength{\hvCapWidth}{\hvSet@capWidth\columnwidth} + \else + \setlength{\hvCapWidth}{\hvMaxCapWidth} + \fi + \fi + \fi +% +% now we have the object and the caption with the right +% rotated angles saved in boxes +% + \def\fps@figure{\hvSet@floatPos} + \ifhv@nonFloat% + \begingroup% Start the nonfloat part + \else% + \begin{\hv@floatType}% Start the floating environment + \fi% + \saveCaptionSkip% we put this space ourselve + \ifx\hvSet@capAngle\hv@Width % need rotation? + \sbox{\hvCaptionBox}{% + \begin{minipage}[b]{\hvCapWidth}% minipage, to get hyphenation + \ifhv@nonFloat% + \ifhv@onlyText% + #2% + \else% + \ifthenelse{\equal{\hv@floatType}{figure}}{% + \ifthenelse{\equal{#1}{}}{\figcaption{#2}}{\figcaption[#1]{#2}}% + }{% + \ifthenelse{\equal{#1}{}}{\tabcaption{#2}}{\tabcaption[#1]{#2}}% + }% + \fi% + \else% + \ifx\hv@shortCap\empty\caption{#2}\else\caption[#1]{#2}\fi% + \fi% + \label{#3}% + \end{minipage}% + }% + \else% + \sbox{\hvCaptionBox}{% + \rotatebox{\hvSet@capAngle}{% + \begin{minipage}[b]{\hvCapWidth}% minipage, to get hyphenation + \ifhv@nonFloat% + \ifhv@onlyText% + #2% + \else% + \ifthenelse{\equal{\hv@floatType}{figure}}{% + \ifthenelse{\equal{#1}{}}{\figcaption{#2}}{\figcaption[#1]{#2}}% + }{% + \ifthenelse{\equal{#1}{}}{\tabcaption{#2}}{\tabcaption[#1]{#2}}% + }% + \fi% + \else% + \ifx\hv@shortCap\empty\caption{#2}\else\caption[#1]{#2}\fi% + \fi% + \label{#3}% + \end{minipage}% + }% + }% + \fi% +%% + \restoreCaptionSkip% save old values + \if@RTL% + \ifx\hvSet@objectPos\hv@Left% + \raggedright% + \else% + \ifx\hvSet@objectPos\hv@Center% + \ifhv@nonFloat% + \hspace*{\fill}% + \else% + \centering + \fi% + \fi% + \fi% + \else + \ifx\hvSet@objectPos\hv@Right% + \raggedleft% + \else% + \ifx\hvSet@objectPos\hv@Center% + \ifhv@nonFloat% + \hspace*{\fill}% + \else% + \centering + \fi% + \fi% + \fi% + \fi +% +% to rotate object and caption together, we save all in another box +% the caption comes first, if its on the left or the top +% + \savebox{\@tempboxa}{\if@RTL% + \ifx\hvSet@capPos\hv@Right % caption on left side + \ifx\hvSet@capVPos\hv@Center% + \ifhv@framedCaption% + \fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}% + \else + \parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}} + \fi% + \hspace{\hvSet@floatCapSep pt}% capfloatsep + \ifhv@framedObject% + \fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}} + \else + \parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}} + \fi% + \else% + \ifx\hvSet@capVPos\hv@Top % caption at top + \ifhv@framedCaption% + \fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}% + \else + \raisebox{-\height}{\usebox{\hvCaptionBox}}% + \fi + \hspace{\hvSet@floatCapSep pt}% capfloatsep + \ifhv@framedObject% + \fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}% + \else + \raisebox{-\height}{\usebox{\hvObjectBox}}% + \fi% + \else% caption on bottom + \ifhv@framedCaption% + \fbox{\usebox{\hvCaptionBox}} + \else + \usebox{\hvCaptionBox} + \fi% + \hspace{\hvSet@floatCapSep pt}% + \ifhv@framedObject% + \fbox{\usebox{\hvObjectBox}} + \else + \usebox{\hvObjectBox} + \fi% + \fi% + \fi% + \else + \ifx\hvSet@capPos\hv@Top + \ifdim\wd\hvCaptionBox>\wd\hvObjectBox + \begin{minipage}{\wd\hvCaptionBox} + \else + \begin{minipage}{\wd\hvObjectBox} + \fi + \centering + \ifhv@framedCaption% + \fbox{\usebox{\hvCaptionBox}}\\[\hvBelowCaptionSkip] + \else + \usebox{\hvCaptionBox}\\[\hvBelowCaptionSkip]% + \fi% + \ifhv@framedObject% + \fbox{\usebox{\hvObjectBox}}% + \else + \usebox{\hvObjectBox}% + \fi% + \end{minipage} + \else + \ifx\hvSet@capPos\hv@Bottom + \ifdim\wd\hvCaptionBox>\wd\hvObjectBox + \begin{minipage}{\wd\hvCaptionBox} + \else + \begin{minipage}{\wd\hvObjectBox} + \fi + \centering + \ifhv@framedObject + \fbox{\usebox{\hvObjectBox}}\\[\hvAboveCaptionSkip] + \else + \usebox{\hvObjectBox}\\[\hvAboveCaptionSkip] + \fi% + \ifhv@framedCaption + \fbox{\usebox{\hvCaptionBox}}% + \else + \usebox{\hvCaptionBox}% + \fi% + \end{minipage} + \else% the last option: put the caption on the right + \ifx\hvSet@capVPos\hv@Center% + \ifhv@framedObject + \fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}} + \else + \parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}} + \fi% + \hspace{\hvSet@floatCapSep pt}% + \ifhv@framedCaption + \fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}% + \else + \parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}} + \fi% + \else% + \ifx\hvSet@capVPos\hv@Top + \ifhv@framedObject + \fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}% + \else + \raisebox{-\height}{\usebox{\hvObjectBox}}% + \fi% + \hspace{\hvSet@floatCapSep pt}% + \ifhv@framedCaption + \fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}% + \else + \raisebox{-\height}{\usebox{\hvCaptionBox}}% + \fi + \else + \ifhv@framedObject + \fbox{\usebox{\hvObjectBox}}% + \else + \usebox{\hvObjectBox}% + \fi + \hspace{\hvSet@floatCapSep pt}% + \ifhv@framedCaption + \fbox{\usebox{\hvCaptionBox}}% + \else + \usebox{\hvCaptionBox}% + \fi% + \fi% + \fi + \fi + \fi + \fi + \else + \ifx\hvSet@capPos\hv@Left % caption on left side + \ifx\hvSet@capVPos\hv@Center% + \ifhv@framedCaption% + \fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}% + \else + \parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}} + \fi% + \hspace{\hvSet@floatCapSep pt}% capfloatsep + \ifhv@framedObject% + \fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}} + \else + \parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}} + \fi% + \else% + \ifx\hvSet@capVPos\hv@Top % caption at top + \ifhv@framedCaption% + \fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}% + \else + \raisebox{-\height}{\usebox{\hvCaptionBox}}% + \fi + \hspace{\hvSet@floatCapSep pt}% capfloatsep + \ifhv@framedObject% + \fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}% + \else + \raisebox{-\height}{\usebox{\hvObjectBox}}% + \fi% + \else% caption on bottom + \ifhv@framedCaption% + \fbox{\usebox{\hvCaptionBox}} + \else + \usebox{\hvCaptionBox} + \fi% + \hspace{\hvSet@floatCapSep pt}% + \ifhv@framedObject% + \fbox{\usebox{\hvObjectBox}} + \else + \usebox{\hvObjectBox} + \fi% + \fi% + \fi% + \else + \ifx\hvSet@capPos\hv@Top + \ifdim\wd\hvCaptionBox>\wd\hvObjectBox + \begin{minipage}{\wd\hvCaptionBox} + \else + \begin{minipage}{\wd\hvObjectBox} + \fi + \centering + \ifhv@framedCaption% + \fbox{\usebox{\hvCaptionBox}}\\[\hvBelowCaptionSkip] + \else + \usebox{\hvCaptionBox}\\[\hvBelowCaptionSkip]% + \fi% + \ifhv@framedObject% + \fbox{\usebox{\hvObjectBox}}% + \else + \usebox{\hvObjectBox}% + \fi% + \end{minipage} + \else + \ifx\hvSet@capPos\hv@Bottom + \ifdim\wd\hvCaptionBox>\wd\hvObjectBox + \begin{minipage}{\wd\hvCaptionBox} + \else + \begin{minipage}{\wd\hvObjectBox} + \fi + \centering + \ifhv@framedObject + \fbox{\usebox{\hvObjectBox}}\\[\hvAboveCaptionSkip] + \else + \usebox{\hvObjectBox}\\[\hvAboveCaptionSkip] + \fi% + \ifhv@framedCaption + \fbox{\usebox{\hvCaptionBox}}% + \else + \usebox{\hvCaptionBox}% + \fi% + \end{minipage} + \else% the last option: put the caption on the right + \ifx\hvSet@capVPos\hv@Center% + \ifhv@framedObject + \fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}} + \else + \parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}} + \fi% + \hspace{\hvSet@floatCapSep pt}% + \ifhv@framedCaption + \fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}% + \else + \parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}} + \fi% + \else% + \ifx\hvSet@capVPos\hv@Top + \ifhv@framedObject + \fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}% + \else + \raisebox{-\height}{\usebox{\hvObjectBox}}% + \fi% + \hspace{\hvSet@floatCapSep pt}% + \ifhv@framedCaption + \fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}% + \else + \raisebox{-\height}{\usebox{\hvCaptionBox}}% + \fi + \else + \ifhv@framedObject + \fbox{\usebox{\hvObjectBox}}% + \else + \usebox{\hvObjectBox}% + \fi + \hspace{\hvSet@floatCapSep pt}% + \ifhv@framedCaption + \fbox{\usebox{\hvCaptionBox}}% + \else + \usebox{\hvCaptionBox}% + \fi% + \fi% + \fi + \fi + \fi + \fi + \fi}% End savebox Object and caption +% +% now we rotate the object and caption, if needed +% + \ifx\hvSet@rotAngle\hv@Zero + \usebox{\@tempboxa} + \else + \rotatebox{\hvSet@rotAngle}{\usebox{\@tempboxa}} + \fi + \ifhv@nonFloat + \ifx\hvSet@objectPos\hv@Center + \ifhv@nonFloat + \hspace{\fill} + \fi + \fi + \endgroup% End the nonfloat part + \else + \end{\hv@floatType}% End the floating environment + \fi + \ifhv@fbox % reset local settings + \setkeys{hvSet}{framedCaption=true, framedObject=true} + \fi +} +% \end{macrocode} +% \iffalse +%</hvfloat-xetex-bidi.def> %<*hyperref-xetex-bidi.def> %\fi % \subsection{\textsf{hyperref-xetex-bidi.def}} @@ -7680,6 +9789,7 @@ Location on CTAN: /macros/latex/contrib/bidi} \bidi@isloaded{xunicode} \bidi@isloaded{wrapfig} \bidi@isloaded{graphicx} +\bidi@isloaded{hvfloat} \bidi@isloaded{hyperref} \bidi@isloaded{fancyhdr} \bidi@isloaded{draftwatermark} @@ -7703,6 +9813,7 @@ Location on CTAN: /macros/latex/contrib/bidi} \bidi@isloaded{multicol} \bidi@isloaded{multienum} \bidi@isloaded{minitoc} +\bidi@isloaded{natbib} \bidi@isloaded{ragged2e} \bidi@isloaded{tabls} \bidi@isloaded{tabulary} @@ -7758,6 +9869,9 @@ Location on CTAN: /macros/latex/contrib/bidi} \if@bidi@graphicxloaded@\else \bidi@isloaded[\PackageError{bidi}{Oops! you have loaded package graphicx after bidi package. Please load package graphicx before bidi package, and then try to run xelatex on your document again}{}]{graphicx} \fi% + \if@bidi@hvfloatloaded@\else + \bidi@isloaded[\PackageError{bidi}{Oops! you have loaded package hvfloat after bidi package. Please load package hvfloat before bidi package, and then try to run xelatex on your document again}{}]{hvfloat} + \fi% \if@bidi@hyperrefloaded@\else \bidi@isloaded[\PackageError{bidi}{Oops! you have loaded package hyperref after bidi package. Please load package hyperref before bidi package, and then try to run xelatex on your document again}{}]{hyperref} \fi% @@ -7827,6 +9941,9 @@ Location on CTAN: /macros/latex/contrib/bidi} \if@bidi@minitocloaded@\else \bidi@isloaded[\PackageError{bidi}{Oops! you have loaded package minitoc after bidi package. Please load package minitoc before bidi package, and then try to run xelatex on your document again}{}]{minitoc} \fi% + \if@bidi@natbibloaded@\else + \bidi@isloaded[\PackageError{bidi}{Oops! you have loaded package natbib after bidi package. Please load package natbib before bidi package, and then try to run xelatex on your document again}{}]{natbib} + \fi% \csname if@bidi@ragged2eloaded@\endcsname\else \bidi@isloaded[\PackageError{bidi}{Oops! you have loaded package ragged2e after bidi package. Please load package ragged2e before bidi package, and then try to run xelatex on your document again}{}]{ragged2e} \fi% @@ -8318,6 +10435,60 @@ Location on CTAN: /macros/latex/contrib/bidi} % \end{macrocode} % \iffalse %</multienum-xetex-bidi.def> +%<*natbib-xetex-bidi.def> +%\fi +% \subsection{\textsf{natbib-xetex-bidi.def}} +% \begin{macrocode} +\ProvidesFile{natbib-xetex-bidi.def}[2011/06/04 v0.1 bidi adaptations for natbib package for XeTeX engine] +\renewenvironment{LTRbibitems}[1][\labelsep] + {\par\@RTLfalse + \ifNAT@numbers + \leftskip\labelwidth + \else + \leftskip\labelsep + \fi + \advance\leftskip #1 + \advance\rightskip -\leftmargin + \ignorespaces}{\endtrivlist} +\renewenvironment{RTLbibitems}[1][\labelsep] + {\par\@RTLtrue + \ifNAT@numbers + \rightskip\labelwidth + \else + \rightskip\labelsep + \fi + \advance\rightskip #1 + \advance\leftskip -\leftmargin + \ignorespaces}{\endtrivlist} +\renewenvironment{thebibliography}[1]{% + \bibsection + \parindent\z@ + \bibpreamble + \bibfont + \if@RTL\if@LTRbibitems\@RTLfalse\else\fi\else\if@RTLbibitems\@RTLtrue\else\fi\fi + \list{\@biblabel{\the\c@NAT@ctr}}{\@bibsetup{#1}\global\c@NAT@ctr\z@}% + \ifNAT@openbib + \renewcommand\newblock{\par}% + \else + \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}% + \fi + \sloppy\clubpenalty4000\widowpenalty4000 + \sfcode`\.\@m + \let\NAT@bibitem@first@sw\@firstoftwo + \let\citeN\cite \let\shortcite\cite + \let\citeasnoun\cite +}{% + \bibitem@fin + \bibpostamble + \def\@noitemerr{% + \PackageWarning{natbib}{Empty `thebibliography' environment}% + }% + \endlist + \bibcleanup +}% +% \end{macrocode} +% \iffalse +%</natbib-xetex-bidi.def> %<*pdfpages-xetex-bidi.def> %\fi % \subsection{\textsf{pdfpages-xetex-bidi.def}} @@ -8401,9 +10572,9 @@ Location on CTAN: /macros/latex/contrib/bidi} %\fi % \subsection{\textsf{plain-xetex-bidi.def}} % \begin{macrocode} -\ifx\TeXXeTstate\undefined\else% - \TeXXeTstate=1 -\fi +\def\TeXXeTOn{\TeXXeTstate=1 } +\def\TeXXeTOff{\TeXXeTstate=0 } +\TeXXeTOn \def\Bidi@RTL@everypar{\if@RTL{\setbox\z@\lastbox\beginR\box\z@}\fi} \let\o@everypar=\everypar \newtoks\n@everypar @@ -8434,18 +10605,16 @@ Location on CTAN: /macros/latex/contrib/bidi} \everyvbox{% \aftergroup\egroup \everyvbox{}% - \beginR + \@RTLtrue \bgroup - \aftergroup\endR \aftergroup\egroup }\vbox} \protected\def\vboxL{\vbox\bgroup \everyvbox{% \aftergroup\egroup \everyvbox{}% - \beginL + \@RTLfalse \bgroup - \aftergroup\endL \aftergroup\egroup }\vbox} \def\LTR{\par\@RTLfalse\@RTL@footnotefalse\hsize\linewidth\parshape\z@} @@ -10665,6 +12834,20 @@ Location on CTAN: /macros/latex/contrib/bidi} % \end{macrocode} % \iffalse %</scrreprt-xetex-bidi.def> +%<*sidecap-xetex-bidi.def> +%\fi +% \subsection{\textsf{sidecap-xetex-bidi.def}} +% \begin{macrocode} +\ProvidesFile{sidecap-xetex-bidi.def}[2010/08/01 v0.1 bidi adaptations for sidecap package for XeTeX engine] +\renewcommand*{\SC@FLOAT}[2]{\if@RTL% + \isSC@ODD{{#1}\hspace{\sidecaptionsep}{#2}} {{#2}\hspace{\sidecaptionsep}{#1}}\else% +\isSC@ODD{{#2}\hspace{\sidecaptionsep}{#1}} {{#1}\hspace{\sidecaptionsep}{#2}}\fi} + \renewcommand*\SC@justify@caption{\if@RTL% +\isSC@ODD{\RaggedLeft}{\RaggedRight}\else% + \isSC@ODD{\RaggedRight}{\RaggedLeft}\fi} +% \end{macrocode} +% \iffalse +%</sidecap-xetex-bidi.def> %<*stabular-xetex-bidi.def> %\fi % \subsection{\textsf{stabular-xetex-bidi.def}} @@ -10815,6 +12998,28 @@ Location on CTAN: /macros/latex/contrib/bidi} \let\\\@centercr \advance\rightskip\z@ \@plus 1fil \parfillskip\z@} +\def\ttlh@hang#1#2#3#4#5#6#7#8{% + \gdef\ttl@makeline##1{\ttl@calc\hspace{#6}##1\ttl@calc\hspace{#7}}% + \setlength\leftskip{#6}% + \setlength\rightskip{#7}% + \interlinepenalty\@M + \ttl@changecentercr + \ttl@beginlongest + #1{\ifhmode\ttl@hmode@error\fi + \ttl@glcmds + \parindent\z@ + \leavevmode + \begingroup + \ifttl@label + \sbox\z@{#2\strut\ttl@calc\hspace{#3}}% + \if@RTL\advance\rightskip\wd\z@\else\advance\leftskip\wd\z@\fi + \llap{\box\z@}% + \fi + #4{#8}% + \kern\z@\strut\@@par + \endgroup + \nobreak\ttl@midlongest#5\@@par}% + \ttl@endlongest} % \end{macrocode} % \iffalse %</titlesec-xetex-bidi.def> @@ -11673,10 +13878,10 @@ Location on CTAN: /macros/latex/contrib/bidi} %\fi % \subsection{\textsf{xetex-bidi.def}} % \begin{macrocode} -\ProvidesFile{xetex-bidi.def}[2010/08/01 v0.8 bidi adaptations for XeTeX engine] -\ifx\TeXXeTstate\undefined\else% - \TeXXeTstate=1 -\fi +\ProvidesFile{xetex-bidi.def}[2011/07/25 v0.9 bidi adaptations for XeTeX engine] +\newcommand{\TeXXeTOn}{\TeXXeTstate=1 } +\newcommand{\TeXXeTOff}{\TeXXeTstate=0 } +\TeXXeTOn \def\Bidi@RTL@everypar{\if@RTL{\setbox\z@\lastbox\beginR\usebox\z@}\fi} \let\o@everypar=\everypar \newtoks\n@everypar @@ -11707,18 +13912,16 @@ Location on CTAN: /macros/latex/contrib/bidi} \everyvbox{% \aftergroup\egroup \everyvbox{}% - \beginR + \@RTLtrue \bgroup - \aftergroup\endR \aftergroup\egroup }\vbox} \protected\def\vboxL{\vbox\bgroup \everyvbox{% \aftergroup\egroup \everyvbox{}% - \beginL + \@RTLfalse \bgroup - \aftergroup\endL \aftergroup\egroup }\vbox} \def\LTR{\par\@RTLfalse\@RTL@footnotefalse\hsize\linewidth\parshape\z@} @@ -11758,6 +13961,8 @@ Location on CTAN: /macros/latex/contrib/bidi} \let\setRL=\setRTL \let\setLR=\setLTR \let\unsetRL=\setLTR +\@ifpackageloaded{mathtools}{\RequirePackage{graphicx}}{} +\@ifpackageloaded{sidecap}{\RequirePackage{ragged2e}}{} \DeclareOption{RTLdocument}{\@RTLtrue\@RTL@footnotetrue\g@addto@macro\document{\autofootnoterule}} \DeclareOption{rldocument}{\@RTLtrue\@RTL@footnotetrue\g@addto@macro\document{\autofootnoterule}} \def\rcases#1{\left.\vcenter{\normalbaselines\m@th @@ -11806,6 +14011,18 @@ Location on CTAN: /macros/latex/contrib/bidi} \advance\rightskip #1 \advance\leftskip -\leftmargin \ignorespaces}{\endtrivlist} +\newenvironment{LTRbibitems}[1][\labelsep] + {\par\@RTLfalse + \leftskip\labelwidth + \advance\leftskip #1 + \advance\rightskip -\leftmargin + \ignorespaces}{\endtrivlist} +\newenvironment{RTLbibitems}[1][\labelsep] + {\par\@RTLtrue + \rightskip\labelwidth + \advance\rightskip #1 + \advance\leftskip -\leftmargin + \ignorespaces}{\endtrivlist} \def\raggedright{% \let\\\@centercr \leftskip\z@skip\rightskip\@flushglue @@ -11964,42 +14181,98 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi} \setlength\@tempdima{#1}% support calc \hb@xt@\@tempdima{\csname bm@#2\endcsname}% \@end@tempboxa} -\def\bm@l{\if@RTL\hss\else\fi\unhbox\@tempboxa\if@RTL\else\hss\fi}\let\bm@t\bm@l -\def\bm@r{\if@RTL\else\hss\fi\unhbox\@tempboxa\if@RTL\hss\else\fi}\let\bm@b\bm@r -\def\endminipage{% - \par - \unskip - \ifvoid\@mpfootins\else - \vskip\skip\@mpfootins - \normalcolor - \footnoterule - \unvbox\@mpfootins - \fi - \@minipagefalse %% added 24 May 89 - \color@endgroup - \egroup - \if@RTL\endL\fi - \egroup - \egroup - \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa\leavevmode}} -\long\def\@iiiparbox#1#2[#3]#4#5{% - \leavevmode - \@pboxswfalse - \setlength\@tempdima{#4}% - \@begin@tempboxa\vbox{\hbox{\if@RTL\beginL\fi\if #1t\vtop\else\vbox\fi{\hsize\@tempdima\@parboxrestore#5\@@par}\if@RTL\endL\fi}}% - \ifx\relax#2\else - \setlength\@tempdimb{#2}% - \edef\@parboxto{to\the\@tempdimb}% - \fi - \if#1b\vbox - \else\if #1t\vtop - \else\ifmmode\vcenter - \else\@pboxswtrue $\vcenter - \fi\fi\fi - \@parboxto{\let\hss\vss\let\unhbox\unvbox - \csname bm@#3\endcsname}% - \if@pboxsw \m@th$\fi - \@end@tempboxa} +\def\bm@l{\if@RTL\hss\else\fi\unhbox\@tempboxa\if@RTL\else\hss\fi} +\def\bm@r{\if@RTL\else\hss\fi\unhbox\@tempboxa\if@RTL\hss\else\fi} +\def\bm@b{\hss\unhbox\@tempboxa} +\def\bm@t{\unhbox\@tempboxa\hss} +\def\LTRmarginpar{% + \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 [\@LTRxmpar\@LTRympar} +\long\def\@LTRxmpar[#1]#2{% + \@LTRsavemarbox\@marbox{#1}% + \@LTRsavemarbox\@currbox{#2}% + \@xympar} +\long\def\@LTRympar#1{% + \@LTRsavemarbox\@marbox{#1}% + \global\setbox\@currbox\copy\@marbox + \@xympar} +\long\def \@LTRsavemarbox #1#2{% + \global\setbox #1% + \color@vbox + \vtop{% + \hsize\marginparwidth + \@parboxrestore + \@LTRmarginparreset + #2% + \@minipagefalse + \outer@nobreak + }% + \color@endbox +} +\def \@LTRmarginparreset {% + \reset@font + \normalsize + \@minipagetrue + \everypar{\@minipagefalse\everypar{}\beginL}% +} +\def\RTLmarginpar{% + \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 [\@RTLxmpar\@RTLympar} +\long\def\@RTLxmpar[#1]#2{% + \@RTLsavemarbox\@marbox{#1}% + \@RTLsavemarbox\@currbox{#2}% + \@xympar} +\long\def\@RTLympar#1{% + \@RTLsavemarbox\@marbox{#1}% + \global\setbox\@currbox\copy\@marbox + \@xympar} +\long\def \@RTLsavemarbox #1#2{% + \global\setbox #1% + \color@vbox + \vtop{% + \hsize\marginparwidth + \@parboxrestore + \@RTLmarginparreset + #2% + \@minipagefalse + \outer@nobreak + }% + \color@endbox +} +\def \@RTLmarginparreset {% + \reset@font + \normalsize + \@minipagetrue + \everypar{\@minipagefalse\everypar{}\beginR}% +} \def\@addmarginpar{\@next\@marbox\@currlist{\@cons\@freelist\@marbox \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne \if@twocolumn @@ -12128,7 +14401,7 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi} \everydisplay\expandafter{\the\everydisplay\predisplaydirection=0 } \def\@eqnnum{{\normalfont \normalcolor \if@RTL\beginR\fi(\theequation)\if@RTL\endR\fi}} \input{footnote-xetex-bidi.def} -\@ifclassloaded{article}{\input{article-xetex-bidi.def}}{} +\@ifclassloaded{article}{\@ifclassloaded{svmult}{}{\input{article-xetex-bidi.def}}}{} \@ifclassloaded{extarticle}{\input{extarticle-xetex-bidi.def}}{} \@ifclassloaded{artikel1}{\input{artikel1-xetex-bidi.def}}{} \@ifclassloaded{artikel2}{\input{artikel2-xetex-bidi.def}}{} @@ -12167,6 +14440,7 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi} \@ifpackageloaded{xltxtra}{\input{xltxtra-xetex-bidi.def}}{} \@ifpackageloaded{wrapfig}{\input{wrapfig-xetex-bidi.def}}{} \@ifpackageloaded{graphicx}{\input{graphicx-xetex-bidi.def}}{} +\@ifpackageloaded{hvfloat}{\input{hvfloat-xetex-bidi.def}}{} \@ifpackageloaded{hyperref}{\input{hyperref-xetex-bidi.def}}{} \@ifpackageloaded{fancyhdr}{\input{fancyhdr-xetex-bidi.def}}{} \@ifpackageloaded{draftwatermark}{\input{draftwatermark-xetex-bidi.def}}{} @@ -12180,12 +14454,36 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi} \@ifpackageloaded{titlesec}{\input{titlesec-xetex-bidi.def}}{} \@ifpackageloaded{titletoc}{\input{titletoc-xetex-bidi.def}}{} \@ifpackageloaded{array}{\input{array-xetex-bidi.def}}{} +\@ifpackageloaded{sidecap}{\input{sidecap-xetex-bidi.def}}{} +\@ifpackagewith{sidecap}{innercaption}{% +\if@RTL \renewcommand*{\SC@FLOAT}[2]{% + \isSC@ODD{{#2}\hspace{\sidecaptionsep}{#1}} {{#1}\hspace{\sidecaptionsep}{#2}}} + \renewcommand*\SC@justify@caption{% + \isSC@ODD{\RaggedRight}{\RaggedLeft}}\else + \renewcommand*{\SC@FLOAT}[2]{% + \isSC@ODD{{#1}\hspace{\sidecaptionsep}{#2}} {{#2}\hspace{\sidecaptionsep}{#1}}} + \renewcommand*\SC@justify@caption{% + \isSC@ODD{\RaggedLeft}{\RaggedRight}}\fi +}{} +\@ifpackagewith{sidecap}{rightcaption}{% + \if@RTL\renewcommand*{\SC@FLOAT}[2]{{#1}\hspace{\sidecaptionsep}{#2}} + \def\SC@justify@caption{\RaggedLeft}\else% + \renewcommand*{\SC@FLOAT}[2]{{#2}\hspace{\sidecaptionsep}{#1}} + \def\SC@justify@caption{\RaggedRight}\fi% +}{} +\@ifpackagewith{sidecap}{leftcaption}{% +\if@RTL \renewcommand*{\SC@FLOAT}[2]{{#2}\hspace{\sidecaptionsep}{#1}} + \def\SC@justify@caption{\RaggedRight}\else% + \renewcommand*{\SC@FLOAT}[2]{{#1}\hspace{\sidecaptionsep}{#2}} + \def\SC@justify@caption{\RaggedLeft}\fi% +}{} \@ifpackageloaded{stabular}{\input{stabular-xetex-bidi.def}}{} \@ifpackageloaded{subfigure}{\input{subfigure-xetex-bidi.def}}{} \@ifpackageloaded{longtable}{\input{longtable-xetex-bidi.def}}{} \@ifpackageloaded{arydshln}{\input{arydshln-xetex-bidi.def}}{} \@ifpackageloaded{multicol}{\input{multicol-xetex-bidi.def}}{} \@ifpackageloaded{multienum}{\input{multienum-xetex-bidi.def}}{} +\@ifpackageloaded{natbib}{\input{natbib-xetex-bidi.def}}{} \@ifpackageloaded{minitoc}{\input{minitoc-xetex-bidi.def}}{} \@ifpackageloaded{quotchap}{\input{quotchap-xetex-bidi.def}}{} \@ifpackageloaded{ragged2e}{\input{ragged2e-xetex-bidi.def}}{} |