0

As seen in this answer about hyperref redefining macros, one ought not use \v when using hyperref. I defined \v to invoke \boldsymbol in a paper and use it 279 times, only later realizing it was pre-defined (I use LyX, which codes all macros via \def). If I load hyperref before this definition, it's fine, but if it loads after, compilation breaks. I don't quite trust my regex skills to do a find-and-replace on \v. So, there appear two alternatives:

  1. (Favorite) Can anyone tell me what hyperref does with \v and what problems to look out for? Maybe I can just ignore it. I searched the hyperref doc and didn't find it.
  2. (Hope to avoid) Can you recommend a LyX tool (ideally) or a script to rename a command and all its invocations in the source?
Werner
  • 603,163
  • \v is not defined by hyperref, it is a standard latex accent command, it is strongly advised not to redefine these. – David Carlisle Feb 07 '22 at 17:55
  • that said if you are confident you have no words with ř and similarly accented letters you could just keep things as they are – David Carlisle Feb 07 '22 at 18:00
  • @DavidCarlisle Of course you are correct, and when I compose in pure text, \newcommand makes sure I don't make such errors. But the other post claims that hyperref re-defines \v for some reason, which I can't find, and that causes the problem. If it just makes the accent different, then I can ignore it, as you say. – James Hunt Feb 07 '22 at 18:05
  • hyperref needs to define all accent commands locally for bookmark processing (that need to be pure text due to pdf internal rules) but it doesn't change the meaning of accents within the document – David Carlisle Feb 07 '22 at 18:10
  • @DavidCarlisle but it would overwrite a definition made before hyperref is loaded. – Ulrike Fischer Feb 07 '22 at 18:12
  • the thing to note is that if you define \v you redefine even if the character is entered as ř , so you need to be careful about foreign names in bibliographies etc. – David Carlisle Feb 07 '22 at 18:13
  • @UlrikeFischer so it does, it ought to be able to define the PU encoded version without changing the current def. – David Carlisle Feb 07 '22 at 18:15
  • @JamesHunt as Ulrike says.... – David Carlisle Feb 07 '22 at 18:17
  • Thank you very much @DavidCarlisle, I am happy to close the question. If you would like to copy your explanation about what hyperref does with accents, I'll accept it. Thank you also Ulrike. – James Hunt Feb 07 '22 at 18:22
  • If LyX does \def when somebody asks for a new command, then it is a really bad choice. Try defining \box – egreg Feb 07 '22 at 18:36
  • @egreg I agree, and they don't even check for clashes. That said, LyX has a lot to offer. Their math interface is great. I have considered AucTeX, except I am a vim person . . . Also, LyX only does \def for math macros, so the damage is semi-contained. If curious, you can see their official (?) stance here. – James Hunt Feb 09 '22 at 10:57
  • @JamesHunt \newcommandx? Oh, dear! I found two other reasons for avoiding LyX, thanks. ;-) – egreg Feb 09 '22 at 11:31

1 Answers1

1

If you are certain you have no letters using the \v accent (such as ř) then you could leave your definition. You should however make sure that hyperref is loaded before your definition otherwise it will over-write your definition as it adjusts accents so that they produce plain text in PDF bookmarks.

David Carlisle
  • 757,742