4

I've just realized that I made a big mistake sometime ago when in my preamble I defined the new command

\renewcommand{\v}{\mathbf{v}}

Now, I'd like to type the czech s using \v{s}, but I can't.

Do you have any suggestions?

3
  • You should, ideally, go back and change your macro to something other than \v throughout your document. If this is infeasible, the, prior to the \renewcommand, issue this: \let\svv\v. Then you can use \svv to capture the original definition. Apr 19, 2016 at 12:45
  • 1
    Normally, such shorthand commands are of limited use and most times a way to shoot yourself into the foot ;-)
    – user31729
    Apr 19, 2016 at 12:48
  • 1
    I would suggest that you change the renewcommand to something which causes an error (almost anything will do). Then when you recompile your document, the error messages will tell you which files have used this command. You can search and replace in each of those files to get rid of all instances of the use of this command. Apr 19, 2016 at 12:56

2 Answers 2

4

Ideally, you should not define your macros using 1-letter names, because of ambiguity. Worse yet, you redefined an existing 1-letter macro name. If going through your document and reversing that usage is not feasible, then one can compensate by saving a copy of the original before redefining it. That way, the original is available under the saved alternate name.

\documentclass{article}
\let\altv\v
\renewcommand{\v}{\mathbf{v}}
\begin{document}
$\v + B = C$

ab\altv ecde
\end{document}

enter image description here

6

Don't do it again! ;-) Count to one million before using \renewcommand and then think twice.

For the document you already have typed, the best thing is to change all \v referring to vectors into something else, say \vecv.

Keeping the same command for doing different things is possible too, but I don't recommend it.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\let\ORIGINALv\v
\DeclareRobustCommand{\v}{%
  \ifmmode\mathbf{v}\else\expandafter\ORIGINALv\fi
}

\begin{document}

\section{\v{c}č}

Háček or h\'{a}\v{c}ek

$\v+x=y$

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .