summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/miller/miller.dtx
blob: c2ce678c5e044428a8ec28dafcdff24d1ba0e3c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
% \iffalse meta comment
% File: miller.dtx Copyright (C) 2003, 2004 Harald Harders, Bj"orn Pedersen
% \fi
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\title{The \texttt{miller} package}
\author{Harald Harders (\texttt{h.harders@tu-bs.de})\\
  Bj\"orn Pedersen (\texttt{bjoern.pedersen@frm2.tum.de})}
\date{Version \fileversion, \filedate}
\EnableCrossrefs
\CodelineIndex
\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
\DoNotIndex{\setcounter,\space}
\CodelineNumbered
\RecordChanges
\CheckSum{159}
\IfFileExists{miller-v.tex}{%
  \input{miller-v.tex}
  \GetFileInfo{miller-v.tex}
}{%
  \PackageError{miller}{File miller-v.tex not found,
    please\MessageBreak 
    run `latex miller.ins' first}{No additional help}%
  \def\fileversion{\textbf{??}}%
  \def\filedate{\textbf{??}}%
}
\usepackage{miller}
\begin{document}
 \DocInput{miller.dtx}
\end{document}
%</driver>
% \fi
%
% \changes{1.0}{2003/04/11}{Changed \cs{millerminus} from \cs{bar} to
%   \cs{overline} due to numbers with more than one digit (HH, BP).}%
% \changes{1.0}{2003/04/11}{Added support to arguments with space and
%   numbers with more than one digit (HH, BP).}%
% \changes{1.1}{2004/04/07}{Bugfix: In some cases, arguments without
%   space have been parsed incorrectly (HH).}%
% \changes{1.1}{2004/04/07}{Bugfix: Detect isolated minus sign in
%   argument with spaces (HH).}%
% \changes{1.1}{2004/04/07}{Add a documentation (HH).}%
%
% \maketitle
% \begin{abstract}
% \noindent
% Typeset miller indices, e.g., $\langle 1\bar20\rangle$, used in
% material sicence with an easy syntax.
% Minus signs are printed as bar above the corresponding number.
% \end{abstract}
%
% \tableofcontents
%
% \section*{Copyright}
% Copyright 2003, 2004 Harald Harders, Bj\"orn Pedersen.
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1.3 of the License, or any later version.
%
% \section{The user interface}
%
% To use this package place
%\begin{verbatim}
%\usepackage{miller}
%\end{verbatim}
% in the preamble of your document.
%
% \DescribeMacro{\hkl}%
% The \cs{hkl} macro can be used in different ways.
% Its argument is surrounded by the parantheses that you want to
% appear in the document.
% If the argument contains spaces, they are taken as delimiters
% between the different components of the hkl vector.
% If no spaces are given, each component has exactly one digit (plus
% eventually a preceeding minus sign).
% The usage is shown with some examples.
%
% \medskip\noindent
% Specify one direction in space:
%\begin{verbatim}
%\hkl[1 12 3], \hkl[-1 0 -12], \hkl[1 11 -2 0]\\
%\hkl[123], \hkl[-10-2], \hkl[11-20]
%\end{verbatim}
%\begin{quote}
%\hkl[1 12 3], \hkl[-1 0 -12], \hkl[1 11 -2 0]\\
%\hkl[123], \hkl[-10-2], \hkl[11-20]
%\end{quote}
% Specify all equal directions in space:
%\begin{verbatim}
%\hkl<1 12 3>, \hkl<-1 0 -12>, \hkl<1 11 -2 0>\\
%\hkl<123>, \hkl<-10-2>, \hkl<11-20>
%\end{verbatim}
%\begin{quote}
%\hkl<1 12 3>, \hkl<-1 0 -12>, \hkl<1 11 -2 0>\\
%\hkl<123>, \hkl<-10-2>, \hkl<11-20>
%\end{quote}
% Specify one plane in space:
%\begin{verbatim}
%\hkl(1 12 3), \hkl(-1 0 -12), \hkl(1 11 -2 0)\\
%\hkl(123), \hkl(-10-2), \hkl(11-20)
%\end{verbatim}
%\begin{quote}
%\hkl(1 12 3), \hkl(-1 0 -12), \hkl(1 11 -2 0)\\
%\hkl(123), \hkl(-10-2), \hkl(11-20)
%\end{quote}
% Specify all equal planes in space:
%\begin{verbatim}
%\hkl{1 12 3}, \hkl{-1 0 -12}, \hkl{1 11 -2 0}\\
%\hkl{123}, \hkl{-10-2}, \hkl{11-20}
%\end{verbatim}
%\begin{quote}
%\hkl{1 12 3}, \hkl{-1 0 -12}, \hkl{1 11 -2 0}\\
%\hkl{123}, \hkl{-10-2}, \hkl{11-20}
%\end{quote}
%
% The first version (with spaces) allows indices with more than one
% digit, while the second one is shorter in the source code.
%
% The symbol used for the bar is changeable by redefining the
% \cs{millerminus} command, e.g.,
%\begin{verbatim}
%\usepackage{ushort}
%\ushortCreate:\overline{oshort}
%\renewcommand\millerminus{\oshort}
%\end{verbatim}
% 
% The space between numbers can be changed, e.g.,
%\begin{verbatim}
%\hkl<123>\\
%\renewcommand\millerskip{\;}\hkl<123>\\
%\renewcommand\millerskip{,\,}\hkl<123>\\
%\renewcommand\millerskip{}\hkl<123>
%\end{verbatim}
%\begin{quote}
%\hkl<123>\\
%\renewcommand\millerskip{\;}\hkl<123>\\
%\renewcommand\millerskip{,\,}\hkl<123>\\
%\renewcommand\millerskip{}\hkl<123>
%\end{quote}
%
% \StopEventually{\PrintChanges \PrintIndex}
%
% \section{The implementation}
%
% Heading of the package:
%    \begin{macrocode}
%<package>\ProvidesPackage{miller}
%<version>\ProvidesFile{miller-v.tex}
%<package|version>  [2004/09/20 v1.2 print miller indices]
%<*package>
%    \end{macrocode}
% Define command for space between numbers.
%    \begin{macrocode}
\newcommand*\millerskip{\,}
%    \end{macrocode}
% Define the command for the minus.
%    \begin{macrocode}
\newcommand*\millerminus{\overline}
%    \end{macrocode}
% Check for space in argument.
%    \begin{macrocode}
\def\@millerno#1 #2\@empty{%
  \xdef\miller@secondarg{#2}%
  \ifx\@empty\miller@secondarg
    \@@@millerno#1#2\@empty\@empty\@empty
  \else
    \@@millerno#1 #2\@empty
  \fi
}%
%    \end{macrocode}
% Parse for minus sign.
%    \begin{macrocode}
\def\@checkminus#1#2\@empty{%
  \ifx-#1%
    \begingroup
    \edef\@tempa{#2}%
    \edef\@tempb{}%
    \ifx\@tempa\@tempb
      \PackageError{miller}{%
        \string\hkl\space command contains a single minus}{No entry of
        the \string\hkl\space command may consist only of a minus.}%
      #1%
    \else
      \millerminus{\vphantom{b}#2}%
    \fi
    \endgroup
  \else
    #1#2%
  \fi
}
%    \end{macrocode}
% Parse the argument (with spaces).
%    \begin{macrocode}
\def\@@millerno#1 #2{%
  \ifx\@empty#2%
    \let\next\relax
  \else%
    \let\next\@@millerno
  \fi%
  \@checkminus#1\@empty
  \ifx\@empty#2\else\millerskip\fi
  \next #2%
}
%    \end{macrocode}
% Parse the argument (without spaces).
%    \begin{macrocode}
\def\@@@millerno#1#2#3{%
  \ifx-#1
    \millerminus{\vphantom{b}#2}%
    \def\miller@nextarg{#3}%
    \ifx\@empty#3%
      \let\next\relax
      \@tempswafalse
      \ifx-#2 \@tempswatrue\fi
      \ifx\@empty#2 \@tempswatrue\fi
      \if@tempswa
        \PackageError{miller}{%
          Last character of \string\hkl\space command is a minus}{The
          last character may not be a minus.}%
      \fi
    \else%
      \let\next\@@@millerno
      \millerskip
    \fi%
  \else
    #1%
    \def\miller@nextarg{#2#3}%
    \ifx\@empty#2%
      \let\next\relax
      \ifx-#1
        \PackageError{miller}{%
          Last character of \string\hkl\space command is a minus}{The
          last character may not be a minus.}%
      \fi
    \else%
      \let\next\@@@millerno
      \millerskip
    \fi%
  \fi
  \expandafter\next\miller@nextarg
}
%    \end{macrocode}
% Commands for the different types.
%    \begin{macrocode}
\def\hkleckig[#1]{\ensuremath{[\@millerno#1 \@empty]}}
\def\hklrund(#1){\ensuremath{(\@millerno#1 \@empty)}}
\def\hklspitz<#1>{\ensuremath{\langle\@millerno#1 \@empty\rangle}}
\def\hklgeschweift#1{\ensuremath{\{\@millerno#1 \@empty\}}}
%    \end{macrocode}
% \begin{macro}{\hkl}
% \changes{1.2}{2004/09/20}{Make \cs{hkl} robust}%
% The command itself.
%    \begin{macrocode}
\DeclareRobustCommand*\hkl{%
  \@ifnextchar[{\hkleckig}{%
    \@ifnextchar({\hklrund}{%
      \@ifnextchar<{\hklspitz}{\hklgeschweift}}}}
%</package>
%    \end{macrocode}
% \end{macro}
%
% \Finale