1

I would not be surprised if this has been asked before, but my searches did not yield any results. Neither would it surprise me if this is not possible without doing some really dangerous hacking of the TeX kernel or something. But allow me to ask anyway.

I use the following code as a shortcut for bold letters in math mode as recommended here:

\documentclass{memoir} \usepackage{amsmath,bm,amsfonts} \def\*#1{\bm{\mathrm{#1}}} \begin{document} Let $\*v$ be a vector in $\mathbb R^n$ with $A\*v = \*v$. \end{document} 

This is nice and handy in most contexts, but it sometimes gets tedious to write \*v inside the argument of other commands. For instance, I may want to write the derivative of \*v as \dot{\*v}. I wonder if there is a way to avoid having to write the {}s. Concretely, what I want is to redefine the command \* so that

$\dot\*v$ 

or even

$\dot\*{longvector}$ 

can be parsed correctly.

7
  • 1
    The problem isn't your definition of \*, but rather the definition of \dot, which takes 1 argument. Without braces, that argument is \*, which is not what you would desire. Commented Mar 22, 2014 at 16:19
  • amsfonts missing? Commented Mar 22, 2014 at 16:19
  • @Sigur, oops, I must have forgotten. Will be corrected. Commented Mar 22, 2014 at 16:22
  • @StevenB.Segletes, yes, I know, but the question if it is possible to cheat LaTeX into parsing the command \* before \dot and with the argument. Commented Mar 22, 2014 at 16:25
  • And preferably, it should work not only with \dot, but in general with commands taking only one argument. Commented Mar 22, 2014 at 16:29

1 Answer 1

3

Maybe this is sufficient for your needs

\def\*#1{{\bm{\mathrm{#1}}}} \let\olddot\dot \def\dot{\expandafter\olddot} 

Note the extra brackets around the body of your \* macro definition: this is to make the expansion of \* look like a single argument to \olddot:

\dot\*v -> \expandafter\olddot\*v -> \olddot{\bm{\mathrm{v}}} 
3
  • Sounds interesting, could you elaborate more on this automation? :-) Commented Mar 22, 2014 at 16:44
  • So I guess it means that there is no way around redefinition the individual commands to be used? Sure it does make everything simpler. ;-) Commented Mar 22, 2014 at 17:01
  • 2
    Well, this was to illustrate the point about needing to redefine \dot. It has to do with the fact that you cannot influence how tokens already consumed by tex are expanded..so, roughly speaking, you cannot change the expansion of \dot by calling something after it. Commented Mar 22, 2014 at 17:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.