I am using hyphen as a letter for command names. But I allow users to rename them if necessary. Then use \catcode`-=11. Suppose I keep the hyphen as a letter in command names, I wonder if users could encounter problems if they keep \catcode`-=11 for the entire document.
- 757,742
- 1
2 Answers
Setting the catcode of the hyphen to letter in a document is a very bad idea. A few examples for a test:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\catcode`-=11
\tikz\draw(0,0)--(1,0); %errors
some long-word-with-hyphenation %errors
\setlength{\parindent}{-1cm} %errors
\end{document}
which errors with
! Package tikz Error: Giving up on this path. Did you forget a semicolon?.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.86 \tikz\draw(0,0)-
-(1,0);
?
! Undefined control sequence.
l.88 some long-word
-with-hyphenation
?
! Undefined control sequence.
l.88 some long-word-with
-hyphenation
?
! Undefined control sequence.
l.88 some long-word-with-hyphenation
?
! Missing number, treated as zero.
<to be read again>
-
l.90 \setlength{\parindent}{-1cm}
?
! Illegal unit of measure (pt inserted).
<to be read again>
-
l.90 \setlength{\parindent}{-1cm}
- 327,261
Some LaTeX constructs that fail if - is catcode 11:
\documentclass[a4paper]{article}
%\catcode`-=11
\usepackage{array}[2021-01-01]
\usepackage{textgreek}
\begin{document}
aaa-bbb-ccc aaa-bbb-ccc aaa-bbb-ccc
aaa-bbb-ccc aaa-bbb-ccc aaa-bbb-ccc
aaa-bbb-ccc aaa-bbb-ccc aaa-bbb-ccc
aaa-bbb-ccc aaa-bbb-ccc aaa-bbb-ccc
aaa-bbb-ccc aaa-bbb-ccc aaa-bbb-ccc
$ \cos-x=\cos x$
$\alpha-\beta$
\textalpha-rays
\verb-\SomeCommand-
\begin{tabular}{lll}
1&2&3\
\cline{2-3}
a&b&ct
\end{tabular}
\end{document}
If you use - internally like @ classically or _ in expl3 you could provide
\DashLetterOn and \DashLetterOff like \makeatletter/\makeatother to allow local access to that syntax in the preamble, but do not use - for commands intended for document use.
- 757,742
-https://tex.stackexchange.com/questions/112831/typesetting-transition-metal-cluster-in-mhchem/112838#112838 https://tex.stackexchange.com/questions/323342/mfuhyphentrue-is-undefined-control-sequence/323348#323348 – user202729 Sep 27 '22 at 00:32