| 1 |
% \iffalse meta comment |
| 2 |
% File: fouridx.dtx Copyright (C) 2008, 2013 Stefan Karrmann |
| 3 |
% \fi |
| 4 |
% |
| 5 |
% \iffalse |
| 6 |
% |
| 7 |
%<*package> |
| 8 |
\def\fileversion{2.00} |
| 9 |
\def\filedate{2013/11/21} |
| 10 |
%</package> |
| 11 |
%<*driver> |
| 12 |
\documentclass{ltxdoc} |
| 13 |
\usepackage[latin1]{inputenc} |
| 14 |
\IfFileExists{fouridx.sty}{\usepackage{fouridx} |
| 15 |
\let\fouridxSTYfound\active}{\GenericWarning{fouridx.dtx}{Package |
| 16 |
file fouridx.sty not found (Documentation will be messed up!^^J^^A |
| 17 |
Generate fouridx.sty by (La)TeXing fouridx.ins, process |
| 18 |
fouridx.dtx again)^^J}\stop} |
| 19 |
\usepackage{longtable} |
| 20 |
\title{The \texttt{fouridx} package\thanks{This file has version |
| 21 |
\fileversion\ last revised \filedate.}} |
| 22 |
\author{Stefan Karrmann\\\texttt{s.karrmann at web.de}} |
| 23 |
\date{File Date \filedate, Printed \today} |
| 24 |
\newlength{\tempdima}% |
| 25 |
\makeatletter |
| 26 |
\renewenvironment{table}[1][]{% |
| 27 |
\@float{table}[#1]% |
| 28 |
\centering% |
| 29 |
\setlength{\tempdima}{\abovecaptionskip}% |
| 30 |
\setlength{\abovecaptionskip}{\belowcaptionskip}% |
| 31 |
\setlength{\belowcaptionskip}{\tempdima}% |
| 32 |
}{% |
| 33 |
\end@float |
| 34 |
} |
| 35 |
\makeatother |
| 36 |
\EnableCrossrefs |
| 37 |
\CodelineIndex |
| 38 |
\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter} |
| 39 |
\DoNotIndex{\setcounter,\space,\if,\else,\fi,\empty,\@empty,\ifx,\fi} |
| 40 |
\DoNotIndex{\ifnum,\fi,\expandafter} |
| 41 |
\CodelineNumbered |
| 42 |
\RecordChanges |
| 43 |
\CheckSum{138} |
| 44 |
\begin{document} |
| 45 |
\DocInput{fouridx.dtx} |
| 46 |
\end{document} |
| 47 |
%</driver> |
| 48 |
% \fi |
| 49 |
% |
| 50 |
% \changes{1.00}{2008/03/27}{Used leftidx.dtx as a template for the |
| 51 |
% English documentation}% |
| 52 |
% \changes{2.00}{2013/11/21}{Bug fixed when line break happens |
| 53 |
% directly at the fouridx command. Thanks to Tilman Schr\"oder. |
| 54 |
% Respect math styles and enables nested calls.}% |
| 55 |
% |
| 56 |
% \maketitle |
| 57 |
% \begin{abstract} |
| 58 |
% \noindent |
| 59 |
% This package enables left subscripts and superscripts in math mode. |
| 60 |
% These subscripts and superscripts are automatically raised for better |
| 61 |
% fitting to the symbol they belong to. This is done in such a way that |
| 62 |
% the left and right subscripts and superscripts are set on the same line, |
| 63 |
% respectivly. |
| 64 |
% \end{abstract} |
| 65 |
% |
| 66 |
% \tableofcontents |
| 67 |
% |
| 68 |
% \section*{Copyright} |
| 69 |
% Copyright 2007, 2013 Stefan Karrmann. |
| 70 |
% |
| 71 |
% This program can be redistributed and/or modified under the terms |
| 72 |
% of the LaTeX Project Public License Distributed from CTAN |
| 73 |
% archives in directory macros/latex/base/lppl.txt; either |
| 74 |
% version 1 of the License, or any later version. |
| 75 |
% |
| 76 |
% \section{Introduction} |
| 77 |
% |
| 78 |
% In mathematical equations, it is sometimes necessary to use indices |
| 79 |
% (subscript or superscript) that are positioned at the left side of a |
| 80 |
% symbol. |
| 81 |
% In tensor mathematics, for instance, some notations use a transponed |
| 82 |
% sign at the left side of the symbol: |
| 83 |
% \begin{eqnarray*} |
| 84 |
% \fourIdx{\mathrm{t}}{}{}{}{\left(A_{ij}\right)} &=& |
| 85 |
% \left(A_{ji}\right) |
| 86 |
% \end{eqnarray*} |
| 87 |
% |
| 88 |
% For symbols with a normal character height, this can be reached by |
| 89 |
% simply put the indices without an own symbol: |
| 90 |
% |
| 91 |
% \noindent |
| 92 |
% \begin{minipage}[c]{0.79\linewidth} |
| 93 |
% \leavevmode\begin{verbatim} |
| 94 |
% ${_1^2}a_3^4$ |
| 95 |
% \end{verbatim} |
| 96 |
% \end{minipage} |
| 97 |
% \begin{minipage}[c]{0.19\linewidth} |
| 98 |
% ${_1^2}a_3^4$ |
| 99 |
% \end{minipage} |
| 100 |
% |
| 101 |
% \noindent |
| 102 |
% Is the symbol larger, this leads to unsatisfactory results: |
| 103 |
% |
| 104 |
% \noindent |
| 105 |
% \begin{minipage}[c]{0.79\linewidth} |
| 106 |
% \leavevmode\begin{verbatim} |
| 107 |
% ${^1_2}\left(\frac{1}{b}\right)^3_4$ |
| 108 |
% \end{verbatim} |
| 109 |
% \end{minipage} |
| 110 |
% \begin{minipage}[c]{0.19\linewidth} |
| 111 |
% ${^1_2}\left(\frac{1}{b}\right)^3_4$ |
| 112 |
% \end{minipage} |
| 113 |
% |
| 114 |
% \noindent |
| 115 |
% If the subscripts on the left and right side are of different height or |
| 116 |
% the left subscripts and superscripts are of different width, |
| 117 |
% the result is also unsatisfactory: |
| 118 |
% |
| 119 |
% \noindent |
| 120 |
% \begin{minipage}[c]{0.79\linewidth} |
| 121 |
% \leavevmode\begin{verbatim} |
| 122 |
% ${^{(k)}_n}A^x_{\overline x\vert}$ |
| 123 |
% \end{verbatim} |
| 124 |
% \end{minipage} |
| 125 |
% \begin{minipage}[c]{0.19\linewidth} |
| 126 |
% ${^{(k)}_n}A^x_{\overline x\vert}$ |
| 127 |
% \end{minipage} |
| 128 |
% |
| 129 |
% \noindent |
| 130 |
% A better output can be reached by using the package |fouridx.sty|: |
| 131 |
% |
| 132 |
% \noindent |
| 133 |
% \begin{minipage}[c]{0.79\linewidth} |
| 134 |
% \leavevmode\begin{verbatim} |
| 135 |
% $\fourIdx{1}{2}{3}{4}{\left(\frac{1}{b}\right)}$ |
| 136 |
% \end{verbatim} |
| 137 |
% \end{minipage} |
| 138 |
% \begin{minipage}[c]{0.19\linewidth} |
| 139 |
% $\fourIdx{1}{2}{3}{4}{\left(\frac{1}{b}\right)}$ |
| 140 |
% \end{minipage} |
| 141 |
% |
| 142 |
% \noindent |
| 143 |
% \begin{minipage}[c]{0.79\linewidth} |
| 144 |
% \leavevmode\begin{verbatim} |
| 145 |
% $\fourIdx{(k)}{n}{x}{\overline x\vert}A$ |
| 146 |
% \end{verbatim} |
| 147 |
% \end{minipage} |
| 148 |
% \begin{minipage}[c]{0.19\linewidth} |
| 149 |
% $\fourIdx{(k)}{n}{x}{\overline x\vert}A$ |
| 150 |
% \end{minipage} |
| 151 |
% \subsection{Old bugs/regression}{ |
| 152 |
% \newcommand{\fourIdxOld}[5]{% |
| 153 |
% \setbox1=\hbox{\ensuremath{^{#1}}}% |
| 154 |
% \setbox2=\hbox{\ensuremath{_{#2}}}% |
| 155 |
% \setbox5=\hbox{\ensuremath{#5}}% |
| 156 |
% \hspace{\ifnum\wd1>\wd2\wd1\else\wd2\fi}% |
| 157 |
% \ensuremath{\copy5^{\hspace{-\wd1}\hspace{-\wd5}#1\hspace{\wd5}#3}% |
| 158 |
% _{\hspace{-\wd2}\hspace{-\wd5}#2\hspace{\wd5}#4}% |
| 159 |
% }} |
| 160 |
% \def\exA{\fourIdxOld 12345} |
| 161 |
% \begin{tabular}[c]{llcc} |
| 162 |
% Error & version & old & actual \\ |
| 163 |
% \hline |
| 164 |
% math style ignored & 1.00 & \(1_{\exA}\) & \(1_{\fourIdx12345}\) \\[1ex] |
| 165 |
% \hline |
| 166 |
% hang over at left after line breaks & 1.00 &\rule[-3ex]{0cm}{7ex} |
| 167 |
% \begin{minipage}{2cm}\noindent\strut\rule{1pt}{2ex}Start of |
| 168 |
% line\hfil\break\exA |
| 169 |
% \end{minipage} |
| 170 |
% & |
| 171 |
% \begin{minipage}{2cm}\noindent\rule{1pt}{2ex}Start of |
| 172 |
% line\hfil\break$\fourIdx12345$ |
| 173 |
% \end{minipage} \\[1ex] |
| 174 |
% \hline |
| 175 |
% wrong positions if nested & 1.00 & \rule{0cm}{5ex} |
| 176 |
% $\vert\fourIdxOld{\fourIdxOld{1}{2}34{51}}{2}{3x}{4}{\fourIdxOld{1}{2}{3}{4}{52}}\vert$ |
| 177 |
% & |
| 178 |
% $\vert\fourIdx{\fourIdx{1}{2}34{51}}{2}{3x}{4}{\fourIdx{1}{2}{3}{4}{52}}\vert$ |
| 179 |
% \\[1ex] |
| 180 |
% \hline |
| 181 |
% \end{tabular} |
| 182 |
% } |
| 183 |
% \subsection{Comparison with sideset} |
| 184 |
% The command sideset from the amsmath package has similiar functionality. |
| 185 |
% It requires that the central box is a math operator an it typesets the |
| 186 |
% left super- and subscript left aligned while fourIdx uses right |
| 187 |
% alignment. Which suits better depends on the purpose. |
| 188 |
% \section{Usage of the package} |
| 189 |
% |
| 190 |
% One command is provided by the package. |
| 191 |
% |
| 192 |
% \DescribeMacro{\fourIdx}% |
| 193 |
% The \cs{fourIdx} command has the syntax |
| 194 |
% \cs{fourIdx}\marg{left superscript}\marg{left subscript}% |
| 195 |
% \marg{right superscript}\marg{right subscript}\marg{symbol}. |
| 196 |
% This command typesets the symbol \meta{symbol} with indices on the |
| 197 |
% left and on the right side. |
| 198 |
% Example: |
| 199 |
% |
| 200 |
% \noindent |
| 201 |
% \begin{minipage}[c]{0.79\linewidth} |
| 202 |
% \leavevmode\begin{verbatim} |
| 203 |
% $\fourIdx1234{\left(\frac{1}{b}\right)}$ |
| 204 |
% \end{verbatim} |
| 205 |
% \end{minipage} |
| 206 |
% \begin{minipage}[c]{0.19\linewidth} |
| 207 |
% $\fourIdx1234{\left(\frac{1}{b}\right)}$ |
| 208 |
% \end{minipage} |
| 209 |
% |
| 210 |
% \noindent |
| 211 |
% You may omit left or right indices by using empty arguments. |
| 212 |
% |
| 213 |
% The next example shows the same in the different mathematical |
| 214 |
% styles: |
| 215 |
% \def\asdf{\fourIdx1234{\left(\frac1b\right)}}% |
| 216 |
% \begin{displaymath} |
| 217 |
% \displaystyle\asdf\quad\textstyle\asdf\quad |
| 218 |
% \scriptstyle\asdf\quad\scriptscriptstyle\asdf |
| 219 |
% \end{displaymath} |
| 220 |
% |
| 221 |
% \StopEventually{\PrintChanges \PrintIndex} |
| 222 |
% |
| 223 |
% \section{The implementation} |
| 224 |
% \iffalse |
| 225 |
%<*package> |
| 226 |
% \fi |
| 227 |
% Heading of the package: |
| 228 |
% \begin{macrocode} |
| 229 |
\NeedsTeXFormat{LaTeX2e}[1995/12/01] |
| 230 |
\ProvidesPackage{fouridx}[\filedate\space v\fileversion\space Four indices] |
| 231 |
% \end{macrocode} |
| 232 |
% \begin{macro}{\fourIdx} |
| 233 |
% \changes{2.00}{2013/11/21}{Bug fix at line breaks, nested calls, and math |
| 234 |
% styles}% |
| 235 |
% \changes{1.00}{2008/03/27}{Implementation simplyfied}% |
| 236 |
% Command for left and right indices. |
| 237 |
% \begin{macrocode} |
| 238 |
\newcommand{\fourIdx}[5]{% |
| 239 |
\ensuremath{\mathchoice% |
| 240 |
{{\setbox1=\hbox{$\scriptstyle{#1}$}% |
| 241 |
\setbox2=\hbox{$\scriptstyle{#2}$}% |
| 242 |
\setbox5=\hbox{$\displaystyle{#5}$}% |
| 243 |
\hspace*{\ifnum\wd1>\wd2\wd1\else\wd2\fi}% |
| 244 |
\copy5^{\scriptstyle\hspace{-\wd1}\hspace{-\wd5}#1\hspace{\wd5}#3}% |
| 245 |
_{\scriptstyle\hspace{-\wd2}\hspace{-\wd5}#2\hspace{\wd5}#4}% |
| 246 |
}}% display |
| 247 |
{{\setbox1=\hbox{$\scriptstyle{#1}$}% |
| 248 |
\setbox2=\hbox{$\scriptstyle{#2}$}% |
| 249 |
\setbox5=\hbox{$\textstyle{#5}$}% |
| 250 |
\hspace*{\ifnum\wd1>\wd2\wd1\else\wd2\fi}% |
| 251 |
\copy5^{\scriptstyle\hspace{-\wd1}\hspace{-\wd5}#1\hspace{\wd5}#3}% |
| 252 |
_{\scriptstyle\hspace{-\wd2}\hspace{-\wd5}#2\hspace{\wd5}#4}% |
| 253 |
}}% text |
| 254 |
{{\setbox1=\hbox{$\scriptscriptstyle{#1}$}% |
| 255 |
\setbox2=\hbox{$\scriptscriptstyle{#2}$}% |
| 256 |
\setbox5=\hbox{$\scriptstyle{#5}$}% |
| 257 |
\hspace*{\ifnum\wd1>\wd2\wd1\else\wd2\fi}% |
| 258 |
\copy5^{\scriptscriptstyle\hspace{-\wd1}\hspace{-\wd5}#1\hspace{\wd5}#3}% |
| 259 |
_{\scriptscriptstyle\hspace{-\wd2}\hspace{-\wd5}#2\hspace{\wd5}#4}% |
| 260 |
}}% script |
| 261 |
{{\setbox1=\hbox{$\scriptscriptstyle{#1}$}% |
| 262 |
\setbox2=\hbox{$\scriptscriptstyle{#2}$}% |
| 263 |
\setbox5=\hbox{$\scriptscriptstyle{#5}$}% |
| 264 |
\hspace*{\ifnum\wd1>\wd2\wd1\else\wd2\fi}% |
| 265 |
\copy5^{\scriptscriptstyle\hspace{-\wd1}\hspace{-\wd5}#1\hspace{\wd5}#3}% |
| 266 |
_{\scriptscriptstyle\hspace{-\wd2}\hspace{-\wd5}#2\hspace{\wd5}#4}% |
| 267 |
}}% scriptscript |
| 268 |
}} |
| 269 |
% \end{macrocode} |
| 270 |
% \end{macro} |
| 271 |
% |
| 272 |
% \iffalse |
| 273 |
%</package> |
| 274 |
% \fi |
| 275 |
% \Finale |