summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/tex/csplain/opmac/opmac.tex103
1 files changed, 67 insertions, 36 deletions
diff --git a/Master/texmf-dist/tex/csplain/opmac/opmac.tex b/Master/texmf-dist/tex/csplain/opmac/opmac.tex
index 6eb8d355ea4..ece2e866a3c 100644
--- a/Master/texmf-dist/tex/csplain/opmac/opmac.tex
+++ b/Master/texmf-dist/tex/csplain/opmac/opmac.tex
@@ -1,11 +1,11 @@
% OPmac
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Petr Olsak, 2012, 2013
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Petr Olsak, 2012, 2013, 2014
%% The history of versions is at the end of this file, after \endpinput
\ifx\OPmacversion\undefined \else \endinput \fi
-\def\OPmacversion{Nov. 2013}
+\def\OPmacversion{Mar. 2014}
\immediate\write16{This is OPmac (Olsak's Plain macros), version <\OPmacversion>}
@@ -96,7 +96,7 @@
\def\cnvhook{} % hook before conversion of outlines
\def\pghook{} % hook in \output rutine
\def\toclinehook{} % hook in \tocline
-\def\mnotehook{} % hook in \mnote to corret its vertical position
+\def\mnotehook{} % hook in \mnote
\def\captionhook#1{} % hook in \caption (#1 is "t" or "f")
%%%%%%%%%%%%%% OPmac, CSplain and LaTeX logos, sec. 3.3 in opmac-d.pdf
@@ -860,10 +860,10 @@
\def\restorecolor{{\def\tmp##1##2##3##4\end{\xdef\savedcolors{##4}%
\def\tmpa{##2}\def\tmpb{##3}\writecolortrue
- \ifx\tmpa\currcolork \else \pdfliteral{##2 k}\xdef\currcolork{##2}%
- \ifnum##1=1 \writecolor k\fi\fi
- \ifx\tmpb\currcolorK \else \pdfliteral{##3 K}\xdef\currcolorK{##3}%
- \ifnum##1=1 \writecolor K\fi\fi}%
+ \ifx\tmpa\empty\else \ifx\tmpa\currcolork\else \pdfliteral{##2 k}\xdef\currcolork{##2}%
+ \ifnum##1=1 \writecolor k\fi\fi\fi
+ \ifx\tmpb\empty\else \ifx\tmpb\currcolorK\else \pdfliteral{##3 K}\xdef\currcolorK{##3}%
+ \ifnum##1=1 \writecolor K\fi\fi\fi}%
\expandafter\tmp\savedcolors\end}}
\addprotect\setcmykcolor \addprotect\localcolor \addprotect\longlocalcolor
@@ -1224,7 +1224,7 @@
\def\rulewidthA{\edef\hrule{\orihrule height\the\tmpdim}%
\edef\vrule{\orivrule width\the\tmpdim}}
-\long\def\frame#1{\setbox0=\hbox{#1}\setbox1=\vbox{\hrule}%
+\long\def\frame#1{\setbox0=\hbox{{#1}}\setbox1=\vbox{\hrule}%
\tmpdim=\dp0 \advance\tmpdim by\ht1 \advance\tmpdim by\hhkern
\vbox{\hrule\hbox{\vrule\kern\vvkern
\vbox{\kern\hhkern\box0\kern\hhkern}\kern\vvkern\vrule}%
@@ -1334,17 +1334,21 @@
\openref\wref\Xmnote{}%
\else \let\tmp=\mnotesfixed \fi
\expandafter\ifx\tmp \left
- \hbox to0pt{\kern-\mnotesize \kern-\mnoteindent
+ \hbox to0pt{\pdfsave\mnoteC\kern-\mnotesize \kern-\mnoteindent
\vbox to0pt{\vss \setbox0=\vtop{\hsize=\mnotesize
- \leftskip=0pt plus 1fill \rightskip=0pt \relax \mnotehook \noindent#1}%
- \dp0=0pt \box0 \kern\mnoteskip \global\mnoteskip=0pt}\hss}%
+ \leftskip=0pt plus 1fill \rightskip=0pt {\mnotehook\noindent#1\endgraf}}%
+ \dp0=0pt \box0 \kern\mnoteskip \global\mnoteskip=0pt}\hss\mnoteD\pdfrestore}%
\else
- \hbox to0pt{\kern\hsize \kern\mnoteindent
+ \hbox to0pt{\pdfsave\mnoteC\kern\hsize \kern\mnoteindent
\vbox to0pt{\vss \setbox0=\vtop{\hsize=\mnotesize
- \rightskip=0pt plus 1fil \leftskip=0pt \relax \mnotehook \noindent#1}%
- \dp0=0pt \box0 \kern\mnoteskip \global\mnoteskip=0pt}\hss}%
+ \rightskip=0pt plus 1fil \leftskip=0pt {\mnotehook\noindent#1\endgraf}}%
+ \dp0=0pt \box0 \kern\mnoteskip \global\mnoteskip=0pt}\hss\mnoteD\pdfrestore}%
\fi
}
+\def\mnoteC{\writecolorfalse \let\longlocalcolor=\localcolor
+ \edef\mnoteD{\xdef\noexpand\currcolork{\currcolork}\xdef\noexpand\currcolorK{\currcolorK}}%
+ \def\currcolork{}\def\currcolorK{}%
+}
\def\Xmnote{\advance\mnotenum by1
\sxdef{mn:\the\mnotenum}{\ifodd\lastpage \right \else \left \fi}}
@@ -1356,37 +1360,55 @@
\newcount\bibnum % the bibitem counter
\newcount\lastcitenum \lastcitenum=0 % for \shortcitations
-\def\cite[#1]{{[\chardef\tmpb=0 \citeA #1,,,%
- \ifnum\tmpb>0 \printdashcite{\the\tmpb}\fi]}}
-\def\nocite[#1]{{\def\docite##1{}\citeA #1,,,}}
-\def\citeA #1#2,{\if#1,\else \rcite{#1#2}\expandafter\citeA\fi}
-\def\citesep{}
+\def\cite[#1]{{\citeA#1,,,[\printsavedcites]}}
+\def\nocite[#1]{{\citeA#1,,,}}
+\def\rcite#1{{\citeA#1,,,\printsavedcites}}
+\def\savedcites{}
-\def\rcite#1{%
+\def\citeA #1#2,{\if#1,\else
\if *#1\addcitelist{*}\expandafter \skiptorelax \fi
- \expandafter \ifx \csname bib:#1\endcsname \relax
- \addcitelist{#1}%
- \opwarning{The cite [#1] unknown. Try to TeX me again}%
- \docite{}\openref
- \expandafter\gdef\csname bib:#1\endcsname {}%
+ \expandafter \ifx \csname bib:#1#2\endcsname \relax
+ \addcitelist{#1#2}%
+ \opwarning{The cite [#1#2] unknown. Try to TeX me again}\openref
+ \addto\savedcites{?,}\def\sortcitesA{}\lastcitenum=0
+ \expandafter\gdef\csname bib:#1#2\endcsname {}%
\expandafter \skiptorelax \fi
- \expandafter \ifx \csname bib:#1\endcsname \empty
- \docite{}%
+ \expandafter \ifx \csname bib:#1#2\endcsname \empty
+ \addto\savedcites{?,}\def\sortcitesA{}\lastcitenum=0
\expandafter \skiptorelax \fi
\def\bibnn##1{}%
- \if &\csname bib:#1\endcsname
- \addcitelist{#1}%
+ \if &\csname bib:#1#2\endcsname
+ \addcitelist{#1#2}%
\def\bibnn##1##2{##1}%
- \sxdef{bib:#1}{\csname bib:#1\endcsname}%
+ \sxdef{bib:#1#2}{\csname bib:#1#2\endcsname}%
\fi
- \docite{\csname bib:#1\endcsname}%
+ \edef\savedcites{\savedcites \csname bib:#1#2\endcsname,}%
\relax
+ \expandafter\citeA\fi
}
-\def\printcite#1{\citesep\citelink{#1}\def\citesep{,\hskip.2em\relax}}
-\def\printdashcite#1{\hbox{--}\citelink{#1}}
+\def\printsavedcites{\sortcitesA
+ \chardef\tmpb=0 \expandafter\citeB\savedcites,%
+ \ifnum\tmpb>0 \printdashcite{\the\tmpb}\fi
+}
+\def\sortcitesA{}
+\def\sortcitations{%
+ \def\sortcitesA{\edef\savedcites{300000,\expandafter}\expandafter\sortcitesB\savedcites,%
+ \def\tmpa####1300000,{\def\savedcites{####1}}\expandafter\tmpa\savedcites}%
+}
+\def\sortcitesB #1,{\if $#1$%
+ \else
+ \mathchardef\tmpa=#1
+ \edef\savedcites{\expandafter}\expandafter\sortcitesC \savedcites\end
+ \expandafter\sortcitesB
+ \fi
+}
+\def\sortcitesC#1,{\ifnum\tmpa<#1\edef\tmpa{\the\tmpa,#1}\expandafter\sortcitesD
+ \else\edef\savedcites{\savedcites#1,}\expandafter\sortcitesC\fi}
+\def\sortcitesD#1\end{\edef\savedcites{\savedcites\tmpa,#1}}
-\def\docite#1{\if$#1$??%
- \else
+\def\citeB#1,{\if$#1$\else
+ \if?#1\relax??%
+ \else
\ifnum\lastcitenum=0 % only comma separated list
\printcite{#1}%
\else
@@ -1404,9 +1426,14 @@
\else
\printdashcite{\the\tmpb}\printcite{#1}\chardef\tmpb=0
\fi\fi\fi\fi\fi
+ \expandafter\citeB\fi
}
\def\shortcitations{\lastcitenum=1 }
+\def\printcite#1{\citesep\citelink{#1}\def\citesep{,\hskip.2em\relax}}
+\def\printdashcite#1{\hbox{--}\citelink{#1}}
+\def\citesep{}
+
\def\bib[#1]{\par \ifnum\bibnum>0 \bibskip \fi
\advance\bibnum by1
\wbib{#1}{\the\bibnum}%
@@ -1672,5 +1699,9 @@ Nov. 2013 \Xpage: \ifnum\lastpage=#1 \else inserted
\cr -> \crcr in \crl, \crll and \crli
\doverbinput: \ifeof\vifile added (bug ``empty line at EOF'' corrected)
eTeX support for multilang added.
+Feb. 2014 \sortcitations introduced, internal macros of \cite rewritten.
+Mar. 2014 \frame: \setbox0=\hbox{{#1}} in order to \aftergroup in #1
+ \mnote: \pdfsave,\pdfrestore inserted, \mnote colors rewritten.
+
%%%%%%%%%%%%%% End of opmac.tex