|
Home Seminararbeiten ' (Apostroph) LaTeX Mathematics Packages Links Zitate Links |
Make LaTeX output a dot when typing an asteriskSimply change the character mapping for math mode:
\DeclareMathSymbol{*}{\mathbin}{symbols}{"01}
The asterisk will still be available with \ast.
Have bold italic math lettersThe standard TeX Computer Modern font set has a bold italic math font (cmmib10), LaTeX added some smaller sizes (cmmib5 etc.). But when \mathbf is used, the font set switches to cmbx, resulting in roman boldface. To get around this, simply define \mathitbf:
\DeclareMathAlphabet{\mathitbf}{OML}{cmm}{b}{it}
If you don't like bold roman in math mode anyway, it is possible to redefine \mathbf with the same command. But be warned: This may
have some unexpected consequences (although I haven't encountered any up
to
now).
You may notice that lowercase greek is not affected by this change, although cmmib includes these glyphs as well. This is because lowercase greek is defined to be resistant against font changes (it is assigned category \mathord). So you may want to redefine the lowercase greek letters to be of category \mathalpha, which follows the font changes:
\DeclareMathSymbol{\alpha}{\mathalpha}{letters}{"0B}
\DeclareMathSymbol{\beta}{\mathalpha}{letters}{"0C}
\DeclareMathSymbol{\gamma}{\mathalpha}{letters}{"0D}
\DeclareMathSymbol{\delta}{\mathalpha}{letters}{"0E}
\DeclareMathSymbol{\epsilon}{\mathalpha}{letters}{"0F}
\DeclareMathSymbol{\zeta}{\mathalpha}{letters}{"10}
\DeclareMathSymbol{\eta}{\mathalpha}{letters}{"11}
\DeclareMathSymbol{\theta}{\mathalpha}{letters}{"12}
\DeclareMathSymbol{\iota}{\mathalpha}{letters}{"13}
\DeclareMathSymbol{\kappa}{\mathalpha}{letters}{"14}
\DeclareMathSymbol{\lambda}{\mathalpha}{letters}{"15}
\DeclareMathSymbol{\mu}{\mathalpha}{letters}{"16}
\DeclareMathSymbol{\nu}{\mathalpha}{letters}{"17}
\DeclareMathSymbol{\xi}{\mathalpha}{letters}{"18}
\DeclareMathSymbol{\pi}{\mathalpha}{letters}{"19}
\DeclareMathSymbol{\rho}{\mathalpha}{letters}{"1A}
\DeclareMathSymbol{\sigma}{\mathalpha}{letters}{"1B}
\DeclareMathSymbol{\tau}{\mathalpha}{letters}{"1C}
\DeclareMathSymbol{\upsilon}{\mathalpha}{letters}{"1D}
\DeclareMathSymbol{\phi}{\mathalpha}{letters}{"1E}
\DeclareMathSymbol{\chi}{\mathalpha}{letters}{"1F}
\DeclareMathSymbol{\psi}{\mathalpha}{letters}{"20}
\DeclareMathSymbol{\omega}{\mathalpha}{letters}{"21}
\DeclareMathSymbol{\varepsilon}{\mathalpha}{letters}{"22}
\DeclareMathSymbol{\vartheta}{\mathalpha}{letters}{"23}
\DeclareMathSymbol{\varpi}{\mathalpha}{letters}{"24}
\DeclareMathSymbol{\varrho}{\mathalpha}{letters}{"25}
\DeclareMathSymbol{\varsigma}{\mathalpha}{letters}{"26}
\DeclareMathSymbol{\varphi}{\mathalpha}{letters}{"27}
Since the roman alphabet does not contain roman
lowercase greek, applying \mathrm to any of these redefined commands
yields
unexpected results. The same holds for \mathsf, \mathtt, …
(Basically this is the same if you did \mathcal{123})
You may want to have a look at the package fixmath, which incorporates these changes. There are some other glyphs that may be useful, too:
\DeclareMathSymbol{\imath}{\mathalpha}{letters}{"7B}
\DeclareMathSymbol{\jmath}{\mathalpha}{letters}{"7C}
Get italic uppercase greek per default(La)TeX defines uppercase greek letters to be roman, what, for example, may lead to confusion between the steradian Ω and the unit of electrical resistance Ω (Ohm). That's why I prefer to have uppercase greek variables in italic but I need to preserve the ability to change to roman with \mathrm or to bold italic with \mathitbf. The solution is simple since one just has to switch uppercase greek from math symbol font ‘operators’ (which normally is connected to cmr) to ‘letters’ (normally cmmi).
\DeclareMathSymbol{\Gamma}{\mathalpha}{letters}{"00}
\DeclareMathSymbol{\Delta}{\mathalpha}{letters}{"01}
\DeclareMathSymbol{\Theta}{\mathalpha}{letters}{"02}
\DeclareMathSymbol{\Lambda}{\mathalpha}{letters}{"03}
\DeclareMathSymbol{\Xi}{\mathalpha}{letters}{"04}
\DeclareMathSymbol{\Pi}{\mathalpha}{letters}{"05}
\DeclareMathSymbol{\Sigma}{\mathalpha}{letters}{"06}
\DeclareMathSymbol{\Upsilon}{\mathalpha}{letters}{"07}
\DeclareMathSymbol{\Phi}{\mathalpha}{letters}{"08}
\DeclareMathSymbol{\Psi}{\mathalpha}{letters}{"09}
\DeclareMathSymbol{\Omega}{\mathalpha}{letters}{"0A}
The package fixmath includes these definitions, too. QuantitiesThe code
\let\unitsep=\, % Inserted at spaces in second arg, separates units (A s)
\let\numunitsep=\; % Separator between number and unit (12.3 V)
\makeatletter
\def\quan#1{\ifmmode \let\@shiftmath=\relax \else \let\@shiftmath=$\fi
\@shiftmath \uppercase{\def\@quanarg{#1}}%
\expandafter\@quannum\@quanarg E\@noexp\@end \futurelet\@nextchar\@quanunit}
\def\@quannum#1E#2\@end{\@quanmant#1\@end \ifx\@noexp#2 \else \@quanexp#2\fi}
\def\@quanmant#1{\ifx#1\@end \let\@next=\relax \else
\if,#1\mathord,\else #1\fi \let\@next=\@quanmant \fi \@next}
\def\@quanexp#1E\@noexp{\times 10^{#1}}
\def\@quanunit{\if[\@nextchar
\def\@next[##1]{\numunitsep\mathrm{##1}\endgroup\@shiftmath}%
\begingroup\@quanspace \else \let\@next=\@shiftmath \fi \@next}
{\catcode`\ =\active\gdef\@quanspace{\catcode`\ =\active\let =\unitsep}}
\makeatother
defines a macro \quan that can be used to typeset quantities with their
physical units. The first (mandatory) argument should be a number, which
optionally may contain the letter ‘e’. If so, a ‘× 10’
is appended and everything after the ‘e’ will be typeset as the
exponent of the 10. Optionally, a second argument, enclosed in square brackets
may be present. If it is, a small skip is attached to the number, and the
second argument is appended in roman type. Note that, in contrast to regular
math mode, spaces in the second argument are not ignored, but
converted to small skips. This makes it easy to visually structure units.
Example:
... evaluates to $x = \quan{1.54e3}[kg m s^2]$, which is ...
yields
… evaluates to x = 1.54 × 103 kg m s2, which is … Upright μSometimes one needs an upright μ to correctly typeset the SI-conform abbreviation of 10-6 (“micro”), for example. Upright lowercase greek unfortunately is not included in the standard Computer Modern font set, so \mathrm{\mu} does not work (see also the remark about \mathitbf). One way out of this is to use the text companion fonts (TC-fonts) that are coming with the EC-fonts, which are standard in every LaTeX distribution now. They provide a command \textmu, which (issued in horizontal mode!) produces the desired upright μ. So what you have to do is add
\usepackage{textcomp}
to your preamble and say
\hbox{\textmu}
every time you need Microvolts, Microamps, Microfarads, or something else.
Defining additional operators(La)TeX has a built-in set of operators like sin, cos, log, …. To add a new definition, you can either use AMSLaTeX's DeclareMathOperator, or simply do it like the LaTeX kernel does it:
\newcommand{\grad}{\mathop{\mathrm{grad}}\nolimits}
\renewcommand{\Re}{\mathop{\mathrm{Re}}\nolimits}
\renewcommand{\Im}{\mathop{\mathrm{Im}}\nolimits}
If you omit nolimits, subscripts are placed directly under the
operator, whereas with nolimits, they appear as regular subscripts.
Smash the width of boxesThe most tricky formula layouts can be achieved with phantom, vphantom and smash. The latter prints its argument in a box of zero height and is useful when setting roots for example. If one has sums or integrals with boundaries (sub- or superscripts) which boxes exceed a certain width, too much white space will surround the sum/integral sign. In this case it would be desireable to have a command to smash the width of a box, centering its content:
\def\clap#1{\hbox to0pt{\hss#1\hss}}
\def\hsmash{\mathpalette\dohsmash}
\def\dohsmash#1#2{\clap{$\mathsurround=0pt#1{#2}$}}
clap is the analogon to rlap and llap and can be used in horizontal mode.
(source: Alexander R. Perlis: A complement to \smash, \llap, and
\rlap. TUGboat, Volume 22 (2001), No. 2)
Multiline equation environmentsLaTeX's standard environment eqnarray produces particularly ugly layouts, which is at large due to the fact that space is added between the three columns. Another annoying thing is that the middle column is set in textstyle, whereas the left and right columns use displaystyle. Furthermore, the three column layout is often not appropriate, because two columns are sufficient to get proper alignment — if lines do not have to be aligned against each other, even a simple one-centered-column approach would make it. But eqnarray would display its middle column in the wrong math style! AMSLaTeX therefore provides (among others) the align and multiline environments. But if that is all you want from AMSLaTeX, you do not have to load the whole package. The following lines are borrowed from the eqnarray definition inside the LaTeX kernel and mimic their AMSLaTeX counterparts:
\makeatletter
\def\eqnalign{%
\stepcounter{equation}%
\def\@currentlabel{\p@equation\theequation}%
\global\@eqnswtrue
\m@th
\global\@eqcnt\z@
\tabskip\@centering
\let\\\@eqncr
$$\everycr{}\halign to\displaywidth\bgroup
\global\@eqcnt\@ne
\hskip\@centering$\displaystyle\tabskip\z@skip{##}$
&\global\@eqcnt\tw@
$\displaystyle{##}$\hfil\tabskip\@centering
&\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
\tabskip\z@skip
\cr
}
\def\endeqnalign{%
\@@eqncr
\egroup
\global\advance\c@equation\m@ne
$$\@ignoretrue
}
\@namedef{eqnalign*}{\def\@eqncr{\nonumber\@seqncr}\eqnalign}
\@namedef{endeqnalign*}{\nonumber\endeqnalign}
\def\eqnlines{%
\stepcounter{equation}%
\def\@currentlabel{\p@equation\theequation}%
\global\@eqnswtrue
\m@th
\global\@eqcnt\z@
\tabskip\@centering
\let\\\@eqncr
$$\everycr{}\halign to\displaywidth\bgroup
\global\@eqcnt\tw@
\hfil$\displaystyle{##}$\hfil\tabskip\@centering
&\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
\tabskip\z@skip
\cr
}
\def\endeqnlines{%
\@@eqncr
\egroup
\global\advance\c@equation\m@ne
$$\@ignoretrue
}
\@namedef{eqnlines*}{\def\@eqncr{\nonumber\@seqncr}\eqnlines}
\@namedef{endeqnlines*}{\nonumber\endeqnlines}
\makeatother
They work exactly like eqnarray, except that eqnalign provides two columns,
and eqnlines one. They have starred cousins eqnalign* and eqnlines* that
do not number the lines. In the regular versions numbering can be inhibited
for a specific line by the use of \nonumber.
|
| © Paul-Jürgen Wagner 8.3.2006 |