%%% ==================================================================== %%% @LaTeX-doc-source-file{ %%% filename = "textcmds.dtx", %%% version = "1.03", %%% date = "2001/12/14", %%% time = "15:31:58 PST", %%% 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 = "58954 223 838 7665", %%% 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} \begin{document} \title{The \pkg{textcmds} package} \author{Michael~J. Downes\\American Mathematical Society} \date{Version \fileversion, \filedate} \hDocInput{textcmds.dtx} \end{document} % % \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 % characters in question\mdash 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}{ll} % \textbf{Command}& \textbf{Definition}\\ % \cn{mdash}& \cn{textemdash}\\ % \cn{ndash}& \cn{textendash}\\ % \cn{qd}& \cn{textquestiondown}\\ % \cn{xd}& \cn{textexclamdown}\\ % \cn{lqq}& \cn{textquotedblleft}\\ % \cn{rqq}& \cn{textquotedblright}\\ % \cn{lq}& \cn{textquoteleft}\\ % \cn{rq}& \cn{textquoteright} % \end{tabular} % \end{center} % % This package also provides short forms for certain text % symbols whose generic name is too long for convenient entry. % \begin{center} % \begin{tabular}{ll} % \textbf{Command}& \textbf{Definition}\\ % \cn{bul}& \cn{textbullet}\\ % \cn{vsp}& \cn{textvisiblespace}\\ % \cn{pdc}& \cn{textperiodcentered}\\ % \cn{vrt}& \cn{textbar}\\ % \cn{cir}& \cn{textasciicircum}\\ % \cn{til}& \cn{textasciitilde}\\ % \cn{bsl}& \cn{textbackslash}\\ % \cn{cwm}& \cn{textcompwordmark}% % \end{tabular} % \end{center} % % Finally, a quoting command \cn{qq} is provided. 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). % % \StopEventually{} % % \section{Implementation} % \begin{macrocode} %<*pkg> % \end{macrocode} % % \begin{macrocode} \ProvidesPackage{textcmds}[2001/12/14 v1.03] % \end{macrocode} % % Dashes and inverted beginning-of-sentence punctuation. % \begin{macrocode} \newcommand{\mdash}{\textemdash\penalty\exhyphenpenalty} \newcommand{\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} \newcommand{\qq}[1]{\ldq#1\rdq} % \end{macrocode} % % Unlike \cs{textsuperscript} and \cs{textsubscript}, these do not % use math mode at all. % \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} % This here definition needs fixing up to not be dependent on cmsy % fonts, but doing it right doesn't look easy so I'm leaving it for % later. [mjd,2000/02/28] % \begin{macrocode} \DeclareRobustCommand{\tprime}{\tsup{\usefont{OMS}{cmsy}{m}{n}\char48 }} % \end{macrocode} % % \begin{macrocode} \csname endinput\endcsname % \end{macrocode} % % \begin{macrocode} % % Say, do you want some Emacs code to convert "--" to \ndash while % you write? And "``" to \qq{ ? Try this stuff. [mjd,2000/04/06] (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))) % % \end{macrocode} % % \CheckSum{117} % \Finale