TeX - LaTeX Asked on August 13, 2020
There’s plenty of questions on this site about redefining specific commands, but I couldn’t find a more general, comprehensive question about the safety and best practices of redefining commands in LaTeX.
Answers to specific parts of this question are welcome, but most likely have already been formulated on this site somewhere; links to those would also be welcome, of course.
Specific recommendations for further reading (chapters in books, specific content on other websites, etc.) are also welcome.
Redefining a Command: what are the implications for packages I’m loading that use said command, for lower-level places that use said command (e.g. the documentclass
, or for higher-level places (mostly meaning just calls to commands from packages which directly or indirectly depended upon the old command), and how do they depend on:
where the original command is defined?
documentclass
I’m using, in the TeX engine I’m using, my own preamble, etc.where the redefined command is defined?
begin{document}
?usepackage{ <package that depends on the old command> }
?bgroup
and egroup
that does / doesn’t make use of some / any functionality of the affected package(s).how the original command is defined?
newcommand
, def
, edef
, protecteddef
, NewDocumentCommand
, DeclareExpandableDocumentCommand
, DeclareRobustCommand
, etc.newcommand{cmd}{ <old content> }
)how the redefined command is defined?
renewcommand
, patchcmd
, xpatchcmd
, RenewDocumentCommand
, RenewExpandableDocumentCommand
, renewrobustcmd
, etc.renewcommand{cmd}{ <new content> }
)whether the old command is renamed with e.g. letoldcmd=cmd
how the old command was being made use of?
Redefining a TeX Primitive (e.g. )…neq
or par
What led me to ask this question, which has popped into my head plenty of times before, was my intention to redefine the TeX primitive d
, whose original definition is (TeXbook p. 356):
defd#1{oalign{#1crcrhidewidth.hidewidth}}
I wanted to redefine it into an all-purpose derivative operator, that e.g. becomes frac{mathop{}!mathrm{d}f}{mathop{}!mathrm{d}x}
when given two arguments, mathop{}!mathrm{d}
when given one, uses partial
when starred, higher derivatives if given an optional argument, etc. How to achieve this particular behavior is, of course, not this question.
Related resources
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP