% \def\filename{textcmds.dtx} % \def\fileversion{2.00} % \def\filedate{2012/08/02} % % \iffalse meta-comment % % American Mathematical Society % Technical Support % Publications Technical Group % 201 Charles Street % Providence, RI 02904 % USA % tel: (401) 455-4080 % (800) 321-4267 (USA and Canada only) % fax: (401) 331-3842 % email: tech-support@ams.org % % Copyright 2001, 2010 American Mathematical Society. % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % This work has the LPPL maintenance status `maintained'. % % The Current Maintainer of this work is the American Mathematical % Society. % % \fi % % \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} \DocInput{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 %^^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'\q{some text}'& \verb'\lq#1\/\rq'& \q{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}[2012/08/02 v2.00] % \end{macrocode} % % Dashes and inverted beginning-of-sentence punctuation. % \begin{macrocode} \providecommand{\mdash}{\textemdash\penalty\exhyphenpenalty} \providecommand{\ndash}{\textendash\penalty\exhyphenpenalty} \providecommand{\qd}{\textquestiondown} \providecommand{\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} \providecommand{\ldq}{\textquotedblleft} \providecommand{\rdq}{\textquotedblright} \providecommand{\lsq}{\textquoteleft} \providecommand{\rsq}{\textquoteright} % \end{macrocode} % % \begin{macrocode} \providecommand{\bul}{\textbullet}% \providecommand{\vsp}{\textvisiblespace}% \providecommand{\pdc}{\textperiodcentered}% \providecommand{\vrt}{\textbar}% \providecommand{\cir}{\textasciicircum}% \providecommand{\til}{\textasciitilde}% \providecommand{\bsl}{\textbackslash}% \providecommand{\cwm}{\textcompwordmark}% % \end{macrocode} % % \begin{macrocode} \providecommand{\qq}[1]{\ldq#1\/\rdq} % \end{macrocode} % % % \begin{macrocode} \providecommand{\q}[1]{\lq#1\/\rq} % \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 % % \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))) % \end{macrocode} % % \CheckSum{138} % \Finale