diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/amslatex/textcmds.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/amslatex/textcmds.dtx | 283 |
1 files changed, 283 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/amslatex/textcmds.dtx b/Master/texmf-dist/source/latex/amslatex/textcmds.dtx new file mode 100644 index 00000000000..cbd82171c0a --- /dev/null +++ b/Master/texmf-dist/source/latex/amslatex/textcmds.dtx @@ -0,0 +1,283 @@ +%%% ==================================================================== +%%% @LaTeX-doc-source-file{ +%%% filename = "textcmds.dtx", +%%% version = "1.05", +%%% date = "2002/04/16", +%%% time = "08:47:47 EDT", +%%% author = "Michael J Downes", +%%% address = "American Mathematical Society, +%%% Publications Technical Group, +%%% PO Box 6248, +%%% Providence, RI 02940, +%%% USA", +%%% email = "tech-support@ams.org", +%%% URL = "http://www.ams.org/", +%%% abstract = "Short forms for textemdash and the other LaTeX +%%% commands that correspond to ligatures of +%%% convenience.", +%%% checksum = "55773 283 1136 10227", +%%% docstring = "The checksum field, produced by Robert Solovay's +%%% checksum utility, gives CRC-16 checksum, lines, +%%% words, and characters.", +%%% } +%%% ==================================================================== +% \iffalse +%<*driver> +\NeedsTeXFormat{LaTeX2e} +\documentclass{amsdtx} +% Undo some things defined by amsdtx.cls +\let\qq=\UnDefined \let\mdash=\UnDefined \let\ndash=\UnDefined +\usepackage{textcmds} +\begin{document} +\title{The \pkg{textcmds} package} +\author{Michael~J. Downes\\American Mathematical Society} +\date{Version \fileversion, \filedate} +\hDocInput{textcmds.dtx} +\end{document} +%</driver> +% \fi +% +% \maketitle +% \section{Introduction} +% +% The \pkg{textcmds} package provides shorthand commands for all the +% text symbols that are traditionally produced in \LaTeX{} documents +% by non-letter ligatures. One of the principal benefits of using +% these commands is that it makes translating your document from +% \LaTeX{} to some other form (e.g., HTML) easier and less bug-prone. +% But it also makes your document less dependent on the use of +% special font metric files having the required ligature information, +% and it makes it far easier to achieve special effects for the +%^^A Either don't use \mdash here, or add textcmds pkg in the driver. +% characters in question\textemdash for example, to add or not to add +% a small amount of extra space around an em-dash character. With the +% ligature method you have to manually add the space for each +% instance, whereas if you use the \verb'\mdash' command, it suffices +% to change the definition of \verb'\mdash' to suit your wishes. +% +% All of these definitions use the preferred +% font-encoding-independent \LaTeX{} commands to obtain the +% characters in question. +% \begin{center} +% \begin{tabular}{lll} +% \textbf{Command}& \textbf{Definition}& \textbf{Result}\\ +% \cn{mdash}& \cn{textemdash}& \mdash\\ +% \cn{ndash}& \cn{textendash}& \ndash\\ +% \cn{qd}& \cn{textquestiondown}& \qd\\ +% \cn{xd}& \cn{textexclamdown}& \xd\\ +% \cn{ldq}& \cn{textquotedblleft}& \ldq\\ +% \cn{rdq}& \cn{textquotedblright}& \rdq\\ +% \cn{lq}& \cn{textquoteleft}& \lq\\ +% \cn{rq}& \cn{textquoteright}& \rq +% \end{tabular} +% \end{center} +% +% This package also provides short forms for certain text +% symbols whose generic name is too long for convenient entry. +% (The \cn{cwm} command does not produce visible output but marks +% word boundaries in a compound word.) +% \begin{center} +% \begin{tabular}{lll} +% \textbf{Command}& \textbf{Definition}& \textbf{Result}\\ +% \cn{bul}& \cn{textbullet}& \bul\\ +% \cn{vsp}& \cn{textvisiblespace}& \vsp\\ +% \cn{pdc}& \cn{textperiodcentered}& \pdc\\ +% \cn{vrt}& \cn{textbar}& \vrt\\ +% \cn{cir}& \cn{textasciicircum}& \cir\\ +% \cn{til}& \cn{textasciitilde}& \til\\ +% \cn{bsl}& \cn{textbackslash}& \bsl\\ +% \cn{cwm}& \cn{textcompwordmark}& \cwm +% \end{tabular} +% \end{center} +% +% Finally, a few other miscellaneous commands are provided, including +% a quoting command \cn{qq}. It seems clearly consonant with other +% parts of \LaTeX{} to write \verb'\qq{...}' to quote a word or short +% phrase rather than \verb'\ldq ...\rdq'; and the use of higher-level +% markup is groundwork that must be laid if one should ever want to +% do anything more sophisticated at the boundaries of a quoted +% expression (such as automatically transposing the quote character +% with following punctuation, if traditional rather than logical +% punctuation style is desired). +% +% \begin{center} +% \begin{tabular}{lll} +% \textbf{Example}& \textbf{Definition}& \textbf{Result}\\ +% \verb'\qq{some text}'& \verb'\ldq#1\rdq'& \qq{some text}\\ +% \verb'\lara{some text}'& \verb'\textlangle#1\textrangle'& +% \lara{some text}\\ +% \verb'Jello\tsup{TM}'& \textit{raise .9ex}\verb'{\supsize#1}'& +% Jello\tsup{TM}\\ +% \verb'Jello\tsub{TM}'& \textit{lower .6ex}\verb'{\supsize#1}'& +% Jello\tsub{TM}\\ +% \verb'a\tprime b'& \verb'\tsup{\textprimechar}'& +% a\tprime b +% \end{tabular} +% \end{center} +% +% \StopEventually{} +% +% \begin{macrocode} +%<*pkg> +% \end{macrocode} +% +% \section{Implementation} +% +% Package name, date, version number. +% \begin{macrocode} +\ProvidesPackage{textcmds}[2002/04/16 v1.05] +% \end{macrocode} +% +% Dashes and inverted beginning-of-sentence punctuation. +% \begin{macrocode} +\providecommand{\mdash}{\textemdash\penalty\exhyphenpenalty} +\providecommand{\ndash}{\textendash\penalty\exhyphenpenalty} +\newcommand{\qd}{\textquestiondown} +\newcommand{\xd}{\textexclamdown} +% \end{macrocode} +% +% Quote commands. Note that \cs{lq} and \cs{rq} are defined in the +% \LaTeX{} kernel to produce functionally different quote characters. +% \begin{macrocode} +\newcommand{\ldq}{\textquotedblleft} +\newcommand{\rdq}{\textquotedblright} +\newcommand{\lsq}{\textquoteleft} +\newcommand{\rsq}{\textquoteright} +% \end{macrocode} +% +% \begin{macrocode} +\newcommand{\bul}{\textbullet}% +\newcommand{\vsp}{\textvisiblespace}% +\newcommand{\pdc}{\textperiodcentered}% +\newcommand{\vrt}{\textbar}% +\newcommand{\cir}{\textasciicircum}% +\newcommand{\til}{\textasciitilde}% +\newcommand{\bsl}{\textbackslash}% +\newcommand{\cwm}{\textcompwordmark}% +% \end{macrocode} +% +% \begin{macrocode} +\providecommand{\qq}[1]{\ldq#1\/\rdq} +% \end{macrocode} +% +% Unlike \cs{textsuperscript} and \cs{textsubscript}, these do not +% use math mode at all. The difference between \cn{scriptsize} and +% \cn{supsize} is that the former is fixed at a single constant size +% regardless of context, whereas the latter adapts to the current +% font size. +% \begin{macrocode} +\newcommand{\supsize}{% +% \end{macrocode} +% Cf \cs{glb@settings}. +% \begin{macrocode} + \expandafter\ifx\csname S@\f@size\endcsname\relax + \calculate@math@sizes + \fi + \csname S@\f@size\endcsname + \fontsize\sf@size\z@\selectfont +} +\DeclareRobustCommand{\tsup}[1]{% + \leavevmode\raise.9ex\hbox{\supsize #1}% +} +\DeclareRobustCommand{\tsub}[1]{% + \leavevmode\lower.6ex\hbox{\supsize #1}% +} +% \end{macrocode} +% +% The \LaTeX{} kernel contains fallback definitions for various +% symbols that traditionally came from the \texttt{cmsy} font: +%\begin{verbatim} +%\DeclareTextSymbolDefault{\textbraceleft}{OMS} +%\end{verbatim} +% But there is no definition of that kind for the cmsy prime +% character that we want to use for \cn{tprime}. So we need to do it +% here. +% \begin{macrocode} +\DeclareTextSymbolDefault{\textprimechar}{OMS} +\DeclareTextSymbol{\textprimechar}{OMS}{48} +\DeclareRobustCommand{\tprime}{\tsup{\textprimechar}} +% \end{macrocode} +% +% And one more pair of symbols that are sometimes useful in text, yet +% do not have suitable text definitions in the \LaTeX{} kernel. (They +% do in the \pkg{textcomp} package.) +% +% If the \pkg{textcmds} package is loaded together with the +% \pkg{textcomp} package, we don't want to clobber the TS1 default. +% \begin{macrocode} +\@ifundefined{textlangle}{% + \DeclareTextSymbolDefault{\textlangle}{OMS} + \DeclareTextSymbolDefault{\textrangle}{OMS} +}{} +\DeclareTextSymbol{\textlangle}{OMS}{"68} +\DeclareTextSymbol{\textrangle}{OMS}{"69} +% \end{macrocode} +% Not sure what's the best name for the angle-brackets analog of the +% \cn{qq} command. How about ``lara'' for ``left-angle right-angle''? +% +% Unlike the quotes case, it is highly unlikely that the font +% contains kern information for the rangle character and the +% character preceding it! So let's put in an italic correction. +% \begin{macrocode} +\DeclareRobustCommand{\lara}[1]{\textlangle#1\/\textrangle} +% \end{macrocode} +% +% \begin{macrocode} +\csname endinput\endcsname +%</pkg> +% \end{macrocode} +% +% Do you want some Emacs code to convert \verb"--" to \cn{ndash} while +% you write? And \verb"``" to \verb'\qq{' ? Try this. +% \begin{macrocode} +<*emacs> +(defvar latex-ndash-command "\\ndash" + "*String to insert for an n-dash in LaTeX mode.") + +(defvar latex-mdash-command "\\mdash" + "*String to insert for an m-dash in LaTeX mode.") + +(defvar latex-quote-command "\\qq" + "*String to insert for quotes in LaTeX mode.") + +(defun latex-maybe-start-quotes (arg) + "Insert the beginning of a \\qq{...} structure if the preceding char is +a left quote." + (interactive "*p") + (if (= (preceding-char) ?\`) + (progn + (delete-backward-char 1) + (insert-and-inherit (concat latex-quote-command "\{"))) + (self-insert-command arg))) + +(defun latex-maybe-end-quotes (arg) + "Insert the end of a \\qq{...} structure if appropriate." + (interactive "*p") + (if (= (preceding-char) ?\') + (progn + (delete-backward-char 1) + (insert-and-inherit "\}")) + (self-insert-command arg))) + +(defun latex-maybe-dash (arg) + "Convert two or three hyphens to \\mdash or \\ndash." + (interactive "*p") + (cond + ((re-search-backward + (concat (regexp-quote latex-ndash-command) " *\\=") nil t) + (replace-match (concat (regexp-quote latex-mdash-command) " "))) + ((= (preceding-char) ?-) + (delete-backward-char 1) + (insert-and-inherit (concat latex-ndash-command " "))) + (t (self-insert-command arg)))) + +(add-hook 'TeX-mode-hook + '(lambda + (define-key LaTeX-mode-map "\`" 'latex-maybe-start-quotes) + (define-key LaTeX-mode-map "\'" 'latex-maybe-end-quotes) + (define-key LaTeX-mode-map "-" 'latex-maybe-dash))) +</emacs> +% \end{macrocode} +% +% \CheckSum{133} +% \Finale |