summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/realscripts
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/realscripts
Initial commit
Diffstat (limited to 'macros/latex/contrib/realscripts')
-rw-r--r--macros/latex/contrib/realscripts/README.md77
-rw-r--r--macros/latex/contrib/realscripts/realscripts.dtx419
-rw-r--r--macros/latex/contrib/realscripts/realscripts.ins58
-rw-r--r--macros/latex/contrib/realscripts/realscripts.pdfbin0 -> 106569 bytes
4 files changed, 554 insertions, 0 deletions
diff --git a/macros/latex/contrib/realscripts/README.md b/macros/latex/contrib/realscripts/README.md
new file mode 100644
index 0000000000..a98194ad9a
--- /dev/null
+++ b/macros/latex/contrib/realscripts/README.md
@@ -0,0 +1,77 @@
+The REALSCRIPTS package
+=======================
+
+Small package to replace `\textsuperscript` & `\textsubscript`
+by equivalent commands that use OpenType font features
+to access the appropriate glyphs if possible.
+
+Provides `\textsubsuperscript` (and `\textsupersubscript`) for
+setting subscripts and superscripts on top of each other.
+
+Also patches LaTeX's default footnote command to use this
+new `\textsuperscript` for footnote symbols.
+
+Requires fontspec running on either XeLaTeX or LuaLaTeX.
+
+For more information see the documentation realscripts.pdf.
+
+Change History
+--------------
+
+v0.3d 2016/02/13
+
+ * Fix somewhat important typo in the documentation.
+ * Minor other updates to the docs.
+ * Fix old expl3 syntax change.
+
+v0.3c 2013/03/18
+
+ * Fix completely broken `\textsupersubscript`.
+ * Allow `\textsubsuperscript` at the start of a paragraph (!).
+ * Sync with expl3 updates.
+
+v0.3b 2013/02/27
+
+ * Remove internal definition of two functions that have since been defined
+ in expl3 (`\dim_min:nn` and `\dim_max:nn`).
+
+v0.3 2010/09/30
+
+ * New commands `\textsubsuperscript` and `\textsupersubscript` added.
+ * Fix an "infinite loop" bug added in the last version, triggered
+ when loading the `xltxtra` package with the `[no-sscript]` option.
+
+
+v0.2 2010/09/20
+
+ * Add feature to specify the font of the patched footnotemark.
+ This behaves well with KOMA-Script's `\setkomafont`, as well.
+
+v0.1
+
+ * First release
+ * Extracted from the xltxtra package
+
+Maintenance
+-----------
+
+The release version of this package is available from CTAN:
+
+* <http://ctan.org/pkg/realscripts>
+
+Development and historical versions are available from GitHub:
+
+* <http://github.com/wspr/realscripts/>
+
+Please report bugs and feature suggestions to the issue tracker:
+
+* <http://github.com/wspr/realscripts/issues>
+
+Licence
+-------
+
+The realscripts package is released under the
+[LaTeX Project Public License](http://www.latex-project.org/lppl/)
+version 1.3c or greater. The current maintainer is Will Robertson.
+
+Copyright 2010 Will Robertson
diff --git a/macros/latex/contrib/realscripts/realscripts.dtx b/macros/latex/contrib/realscripts/realscripts.dtx
new file mode 100644
index 0000000000..e59103e55a
--- /dev/null
+++ b/macros/latex/contrib/realscripts/realscripts.dtx
@@ -0,0 +1,419 @@
+% \iffalse
+%
+%<*internal>
+\begingroup
+%</internal>
+%<*batchfile>
+\input docstrip.tex
+\keepsilent
+\preamble
+ _____________________________
+ The REALSCRIPTS package
+ (C) 2010--2016 Will Robertson
+ License information appended
+
+\endpreamble
+\postamble
+
+Copyright (C) 2010--2016 by Will Robertson <will.robertson@latex-project.org>
+
+Distributable under the LaTeX Project Public License,
+version 1.3c or higher (your choice). The latest version of
+this license is at: http://www.latex-project.org/lppl.txt
+
+This work is "maintained" (as per LPPL maintenance status)
+by Will Robertson.
+
+This work consists of the file realscripts.dtx
+ and the derived files realscripts.sty,
+ realscripts.ins, and
+ realscripts.pdf.
+
+\endpostamble
+\askforoverwritefalse
+\generate{\file{realscripts.sty}{\from{realscripts.dtx}{package}}}
+%</batchfile>
+%<batchfile>\endbatchfile
+%<*internal>
+\generate{\file{realscripts.ins}{\from{realscripts.dtx}{batchfile}}}
+\def\tmpa{plain}
+\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi
+\endgroup
+%</internal>
+%
+% \begin{macrocode}
+%<*driver>
+\ProvidesFile{realscripts.dtx}
+%</driver>
+%<package>\ProvidesPackage{realscripts}
+%<*package>
+ [2016/02/13 v0.3d Access OpenType subscripts and superscripts]
+%</package>
+% \end{macrocode}
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{color,graphicx,metalogo,hologo,fontspec,realscripts}
+\linespread{1.05} % A bit more space between lines
+\frenchspacing % Remove extra space after punctuation
+\definecolor{niceblue}{rgb}{0.1,0.2,1}
+\def\theCodelineNo{\textcolor{niceblue}{\sffamily\tiny\arabic{CodelineNo}}}
+\newcommand*\pkg[1]{\texttt{#1}}
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+%
+% \fi
+%
+% \errorcontextlines=999
+% \makeatletter
+%
+% \GetFileInfo{\jobname.sty}
+%
+% \title{The \pkg{\jobname} package}
+% \author{Will Robertson}
+% \date{\filedate \qquad \fileversion}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% OpenType fonts provide the possiblity of using specially-drawn glyphs for
+% subscript and superscript text. \LaTeX\ by default simply uses a smaller
+% font size, which is acceptable if the font has optical sizes. Most fonts
+% don't, however.
+%
+% If you are using the \pkg{fontspec} package\footnote{The \pkg{fontspec} package requires \XeLaTeX\ or \hologo{LuaLaTeX}.} to select OpenType fonts
+% (or other sorts of fonts with the necessary font features), then loading
+% this package will redefine the \cmd\textsuperscript\ and
+% \cmd\textsubscript\ commands that take advantage of the OpenType font
+% features.
+%
+% The \cs{textsubsuperscript}\marg{sub}\marg{super} command is
+% defined for typesetting superscripts above subscripts using the same
+% approach. For symmetry, \cs{textsupersubscript}\marg{super}\marg{sub}
+% is also provided. Options are available to specify the alignment of the sub- and super-scripts; see below.
+%
+% \section{Technical details}
+%
+% The old commands are defined in starred form (e.g., \cs{textsubscript*}) for cases where the new commands are not appropriate.
+% The functionality of the starred and non-starred commands can
+% also be accessed using the macros
+% \cmd\realsubscript,
+% \cmd\realsuperscript,
+% \cmd\fakesubscript, and
+% \cmd\fakesuperscript, in case another package (or you)
+% redefine the original \cmd\text\dots\ commands.
+%
+% This package will also patch the default \LaTeX\ footnote mechanism to
+% use \cs{textsuperscript} automatically. You may change the font used
+% to typeset the footnote numbers (by default it is the \cs{normalfont})
+% by redefining \cs{footnotemarkfont}; e.g.:
+% {\par\qquad\verb|\renewcommand\footnotemarkfont|\marg{font switch}\par}
+% \noindent and users of \pkg{KOMA-Script} may use instead
+% {\par\qquad\verb|\setkomafont{footnotelabel}|\marg{font switch}\par}
+% \noindent where \meta{font switch} is a command such as \cs{sffamily} or a \pkg{fontspec} font defined with \cs{newfontfamily}.
+%
+% Beware of other packages, however, that change the footnote mechanism. (Usually by redefining \cs{@makefnmark}.) I can often work around or work with such packages so \pkg{realscripts} cooperates gracefully with them; please report any conflicts to me.
+%
+% \section{Examples}
+%
+% Here is an example using the `{\fontspec{Skia} Skia}' font of Mac\,OS\,X: (surrounded by `A' and `Z' for visual context)
+%
+% \begin{quotation}\color{niceblue}
+% \fontspec{Skia}
+% |\textsuperscript{…} | A \textsuperscript{abcdefghijklmnopqrstuvwxyz1234567890} Z\par
+% |\textsubscript{…} | A \textsubscript{abcdefghijklmnopqrstuvwxyz1234567890} Z
+% \end{quotation}
+% The original definitions are available in starred verions of the commands:
+% (compare this example to that above to see why using these features is often desirable)
+% \begin{quotation}\color{niceblue}
+% \fontspec{Skia}
+% |\textsuperscript*{…} | A \textsuperscript*{abcdefghijklmnopqrstuvwxyz1234567890} Z\par
+% |\textsubscript*{…} | A \textsubscript*{abcdefghijklmnopqrstuvwxyz1234567890} Z
+% \end{quotation}
+% When the font features are not available the commands will fall back on the standard technique of scaling down the text font:
+% (this is Mac\,OS\,X's `{\fontspec{Didot} Didot}')
+% \begin{quotation}\color{niceblue}
+% \fontspec{Didot}
+% |\textsuperscript{…} | A \textsuperscript{abcdefghijklmnopqrstuvwxyz1234567890} Z\par
+% |\textsubscript{…} | A \textsubscript{abcdefghijklmnopqrstuvwxyz1234567890} Z
+% \end{quotation}
+% But beware fonts that contain the necessary font features but lack the full repertoire of glyphs: (this is `{\fontspec{Adobe Jenson Pro}Adobe Jenson Pro}')
+% \begin{quotation}\color{niceblue}
+% \fontspec{Adobe Jenson Pro}
+% |\textsuperscript{…} | A {\textsuperscript{abcdefghijklmnopqrstuvwxyz1234567890}} Z\par
+% |\textsubscript{…} | A {\textsubscript{abcdefghijklmnopqrstuvwxyz1234567890}} Z
+% \end{quotation}
+% Finally, the `combined' commands. Note the dimension available
+% to add some extra space between the sub- and super-scripts, and
+% the optional argument for specifying alignment.
+% \begin{quotation}\color{niceblue}
+% \fontspec{Skia}
+% |\textsubsuperscript{…}{…} |
+% A {\textsubsuperscript{123456}{789}} Z\par\smallskip
+% |\setlength\subsupersep{2pt} | \subsupersep=2pt
+% A {\textsubsuperscript{123456}{789}} Z\par\smallskip
+% |\textsubsuperscript[c]{…}{…} |
+% A {\textsubsuperscript[c]{123}{456789}} Z\par\smallskip
+% |\textsubsuperscript[r]{…}{…} |
+% A {\textsubsuperscript[r]{123456}{789}} Z\par\smallskip
+% \end{quotation}
+%
+% \newpage
+% \part{Implementation of \textsf{\jobname}}
+%\iffalse
+%<*package>
+%\fi
+% This is the package implementation.
+% If you're only interested in the footnote redefinition,
+% skip ahead to Section~\ref{sec:fn} on page~\pageref{sec:fn}.
+%
+% \begin{macrocode}
+\RequirePackage{fontspec}
+\ExplSyntaxOn
+% \end{macrocode}
+%
+% \begin{macro}{\fakesubscript}
+% \begin{macro}{\fakesuperscript}
+% The old (`fake') methods.
+% Because \cs{textsubscript} is not defined in \LaTeXe,
+% we either define it from scratch along with \cs{textsuperscript}
+% (for consistency).
+% \begin{macrocode}
+\DeclareDocumentCommand \fakesubscript {m} {
+ \@textsubscript{\selectfont#1}
+}
+\DeclareDocumentCommand \fakesuperscript {m} {
+ \@textsuperscript{\selectfont#1}
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\textsubscript}
+% \begin{macro}{\textsubscript*}
+% \begin{macro}{\textsuperscript}
+% \begin{macro}{\textsuperscript*}
+% These commands are either defined to create fake or real sub-/super-scripts if they are starred or not, respectively.
+% \begin{macrocode}
+\RenewDocumentCommand \textsubscript {s} {
+ \IfBooleanTF #1 \fakesubscript \realsubscript
+}
+\RenewDocumentCommand \textsuperscript {s} {
+ \IfBooleanTF #1 \fakesuperscript \realsuperscript
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\realsubscript}
+% The new subscript command to use rich font features if possible.
+% \begin{macrocode}
+\DeclareDocumentCommand \realsubscript {m} {
+ \fontspec_if_fontspec_font:TF {
+% \end{macrocode}
+% For OpenType fonts, the subscript feature (|subs|) is used, but if that doesn't
+% exist then the scientific inferior feature (|sinf|) is used on the assumption
+% that something's better than nothing.
+% \begin{macrocode}
+ \fontspec_if_opentype:TF
+ { \fontspec_if_feature:nTF {+subs}
+ { {\addfontfeature{VerticalPosition=Inferior}#1} }
+ { \fontspec_if_feature:nTF {+sinf}
+ { {\addfontfeature{VerticalPosition=ScientificInferior}#1} }
+ { \fakesubscript{#1} }
+ }
+ }
+% \end{macrocode}
+% ATSUI fonts:
+% \begin{macrocode}
+ { \fontspec_if_aat_feature:nnTF {10} {2}
+ { {\addfontfeature{VerticalPosition=Inferior}#1} }
+ { \fakesubscript{#1} }
+ }
+ }
+% \end{macrocode}
+% Non-fontspec fonts:
+% \begin{macrocode}
+ { \fakesubscript{#1} }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\realsuperscript}
+% The new superscript command to use rich font features if possible.
+% \begin{macrocode}
+\DeclareDocumentCommand \realsuperscript {m} {
+ \fontspec_if_fontspec_font:TF
+ {
+% \end{macrocode}
+% OpenType fonts:
+% \begin{macrocode}
+ \fontspec_if_opentype:TF
+ { \fontspec_if_feature:nTF {+sups}
+ { {\addfontfeature{VerticalPosition=Superior}#1} }
+ { \fakesuperscript{#1} }
+ }
+% \end{macrocode}
+% ATSUI fonts:
+% \begin{macrocode}
+ { \fontspec_if_aat_feature:nnTF {10} {1}
+ { {\addfontfeature{VerticalPosition=Superior}#1} }
+ { \fakesuperscript{#1} }
+ }
+ }
+% \end{macrocode}
+% Non-fontspec fonts:
+% \begin{macrocode}
+ { \fakesuperscript{#1} }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Patching footnotes}
+% \label{sec:fn}
+%
+% \begin{macro}{\@makefnmark}
+% This is the command used to typeset the `footnote mark'.
+% Feel free to redefine it as necessary for your own purposes.
+% \begin{macrocode}
+\cs_set:Npn \@makefnmark {
+ \mbox{\footnotemarkfont\textsuperscript{\@thefnmark}}
+}
+% \end{macrocode}
+% We define a \cs{footnotemarkfont} that is used to style
+% the number used for the footnote, which by default is
+% simply \cs{normalfont} (following \LaTeXe's default).
+% If \pkg{KOMA-Script} is
+% being used, we use their hook for the footnotemark font instead.
+% \begin{macrocode}
+\cs_if_exist:NTF \ftntm@font
+{
+ \cs_new:Npn \footnotemarkfont {\ftntm@font}
+}
+{
+ \cs_new:Npn \footnotemarkfont {\normalfont}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{sub+super}
+%
+% \begin{macro}{\textsubsuperscript}
+% \begin{macro}{\textsupersubscript}
+% Although the implementation below would be fine outside of this package too,
+% no point writing yet another small package.
+% \begin{macrocode}
+\DeclareDocumentCommand \textsubsuperscript {s O{l} mm} {
+ \leavevmode
+ \group_begin:
+ \IfBooleanTF #1
+ {
+ \hbox_set:Nn \l_tmpa_box {\textsubscript*{#3}}
+ \hbox_set:Nn \l_tmpb_box {\textsuperscript*{#4}}
+ }
+ {
+ \hbox_set:Nn \l_tmpa_box {\textsubscript{#3}}
+ \hbox_set:Nn \l_tmpb_box {\textsuperscript{#4}}
+ }
+ \hbox_set:Nn \l_tmpa_box
+ { \box_move_down:nn \subsupersep {\box_use:N \l_tmpa_box} }
+ \hbox_set:Nn \l_tmpb_box
+ { \box_move_up:nn \subsupersep {\box_use:N \l_tmpb_box} }
+ \str_case:nnF {#2}
+ {
+ {l}{\use_i:nnn}
+ {c}{\use_ii:nnn}
+ {r}{\use_iii:nnn}
+ }
+ {
+ \PackageWarning{realscripts}{
+ Unknown~alignment~option~`#2'. \MessageBreak
+ One~ of~ `l',~ `c',~ `r',~ only
+ }
+ \use_i:nnn
+ }
+% \end{macrocode}
+% Left aligned:
+% \begin{macrocode}
+ {
+ \hbox_overlap_right:n { \box_use:N \l_tmpa_box }
+ \hbox_overlap_right:n { \box_use:N \l_tmpb_box }
+ \skip_horizontal:n {
+ \dim_max:nn {\box_wd:N \l_tmpa_box} {\box_wd:N \l_tmpb_box}
+ }
+ }
+% \end{macrocode}
+% Center aligned: (for completeness)
+% \begin{macrocode}
+ {
+ \dim_compare:nTF { \box_wd:N \l_tmpa_box > \box_wd:N \l_tmpb_box }
+ {
+ \skip_horizontal:n {
+ 0.5\box_wd:N \l_tmpa_box-0.5\box_wd:N \l_tmpb_box
+ }
+ \box_use:N \l_tmpb_box
+ \skip_horizontal:n {
+ -0.5\box_wd:N \l_tmpa_box-0.5\box_wd:N \l_tmpb_box
+ }
+ \box_use:N \l_tmpa_box
+ }
+ {
+ \skip_horizontal:n {
+ 0.5\box_wd:N \l_tmpb_box-0.5\box_wd:N \l_tmpa_box
+ }
+ \box_use:N \l_tmpa_box
+ \skip_horizontal:n {
+ -0.5\box_wd:N \l_tmpb_box-0.5\box_wd:N \l_tmpa_box
+ }
+ \box_use:N \l_tmpb_box
+ }
+ }
+% \end{macrocode}
+% Right aligned:
+% \begin{macrocode}
+ {
+ \skip_horizontal:n {
+ \dim_max:nn {\box_wd:N \l_tmpa_box} {\box_wd:N \l_tmpb_box}
+ }
+ \hbox_overlap_left:n { \box_use:N \l_tmpa_box }
+ \hbox_overlap_left:n { \box_use:N \l_tmpb_box }
+ }
+ \group_end:
+}
+\DeclareDocumentCommand \textsupersubscript {s O{l} mm} {
+ \IfBooleanTF #1
+ { \textsubsuperscript * [#2] {#4} {#3} }
+ { \textsubsuperscript [#2] {#4} {#3} }
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\dim_new:N \subsupersep
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Fin.
+%
+%\iffalse
+%</package>
+%\fi
+%
+% \Finale
+%
+% \typeout{*************************************************************}
+% \typeout{*}
+% \typeout{* To finish the installation you have to move the following}
+% \typeout{* file into a directory searched by XeTeX:}
+% \typeout{*}
+% \typeout{* \space\space\space realscripts.sty}
+% \typeout{*}
+% \typeout{*************************************************************}
+%
+\endinput
+
diff --git a/macros/latex/contrib/realscripts/realscripts.ins b/macros/latex/contrib/realscripts/realscripts.ins
new file mode 100644
index 0000000000..c68d0669cd
--- /dev/null
+++ b/macros/latex/contrib/realscripts/realscripts.ins
@@ -0,0 +1,58 @@
+%%
+%% This is file `realscripts.ins',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% realscripts.dtx (with options: `batchfile')
+%% _____________________________
+%% The REALSCRIPTS package
+%% (C) 2010--2016 Will Robertson
+%% License information appended
+%%
+\input docstrip.tex
+\keepsilent
+\preamble
+ _____________________________
+ The REALSCRIPTS package
+ (C) 2010--2016 Will Robertson
+ License information appended
+
+\endpreamble
+\postamble
+
+Copyright (C) 2010--2016 by Will Robertson <will.robertson@latex-project.org>
+
+Distributable under the LaTeX Project Public License,
+version 1.3c or higher (your choice). The latest version of
+this license is at: http://www.latex-project.org/lppl.txt
+
+This work is "maintained" (as per LPPL maintenance status)
+by Will Robertson.
+
+This work consists of the file realscripts.dtx
+ and the derived files realscripts.sty,
+ realscripts.ins, and
+ realscripts.pdf.
+
+\endpostamble
+\askforoverwritefalse
+\generate{\file{realscripts.sty}{\from{realscripts.dtx}{package}}}
+\endbatchfile
+%%
+%% Copyright (C) 2010--2016 by Will Robertson <will.robertson@latex-project.org>
+%%
+%% Distributable under the LaTeX Project Public License,
+%% version 1.3c or higher (your choice). The latest version of
+%% this license is at: http://www.latex-project.org/lppl.txt
+%%
+%% This work is "maintained" (as per LPPL maintenance status)
+%% by Will Robertson.
+%%
+%% This work consists of the file realscripts.dtx
+%% and the derived files realscripts.sty,
+%% realscripts.ins, and
+%% realscripts.pdf.
+%%
+%%
+%% End of file `realscripts.ins'.
diff --git a/macros/latex/contrib/realscripts/realscripts.pdf b/macros/latex/contrib/realscripts/realscripts.pdf
new file mode 100644
index 0000000000..dc2e2e8dc7
--- /dev/null
+++ b/macros/latex/contrib/realscripts/realscripts.pdf
Binary files differ