I am defining some custom commands for latex documents. Do names for \def, \newcommand, and \newenvironment not accept - and _ ?
Asked
Active
Viewed 73 times
0
Veak
- 1
\-or\_– David Carlisle Sep 05 '22 at 21:49@if you're writing a package or document class (where\makeatletteris on) and the commands are only used internally to it. – frabjous Sep 05 '22 at 21:55\-or\_used in the definition only? – Veak Sep 05 '22 at 22:02@or is done for internal use only. The reason I would have liked to use something likemy-toolis that the words are separated and I do not need to use the shift key. – Veak Sep 05 '22 at 22:25-in names for\def,\newcommand,\newenvironment. Things could became much more systematic, and comparable tolisp, a very appealing language in regards to naming and documentation conventions. Is there a problem hampering this change? – Veak Sep 06 '22 at 09:31\alpha-\betaor\textgamma-rayor ... Not to mention invalidating every existing latex tutorial. Note the change is trivial\catcode \-=11will make-` a letter, but you should not do it except in controlled evironments – David Carlisle Sep 06 '22 at 09:42recutils. Mostly because there was not much thought about hyphenated words and resulting conflicts. Been scrutinising your comment. One rule would be that names can only be inter-hyphenated, with affixed hyphens at the end being disallowed. – Veak Sep 06 '22 at 10:04\def\galex\-pipe{textbf{|}}fallowed by\newcommand{\galex\-bfblue}[1]{\textcolor{blue}{\textbf{#1}}}gives the latex errorCommand \galex already defined.withl.38 ...x\-bfblue}[1]{\textcolor{blue}{\textbf{#1}}}. – Veak Sep 06 '22 at 11:41\mytoolCommand,\myToolCommand,\mytoolcommand,\mtcommandetc. then it is not worth all the trouble in my opinion. – Marijn Sep 06 '22 at 12:38\galex@pipe, then one can change the name in there documents in case of conflicts\let\pipe\galex@pipe. – Veak Sep 06 '22 at 12:40latex3which should be the long-term project developing the next version oflatex. – Veak Sep 06 '22 at 12:44hyphented-wordsis a superior system for readability, and go a long time back, up the first programming languages such aslisp. – Veak Sep 06 '22 at 12:47\in LaTeX) such as Perl or PHP. – Marijn Sep 06 '22 at 12:51@for latex to help avoid package conflicts, when hyphented words would be more natural. Could be just me, but these things have to be part of the design. Nevertheless, I am utilising@for this rather thanCamel Case. – Veak Sep 06 '22 at 13:54-a letter allowed in command names but then essentially you are defining a domain specific language it's no longer latex – David Carlisle Sep 06 '22 at 15:58\-or\_, which although not standard, can be done. Without pointing out what settings would be needed. Without that information, their introduction gets latex complaining. Although I can see that\-or\_do not really provide an improvement, making the use of the@way more appealing. – Veak Sep 06 '22 at 16:07-or@or::or camelcase, and much less a question of design. – Marijn Sep 06 '22 at 16:18@though. Disallowing punctuation in names is a design decision nevertheless (historically-and_have been a common occurrence, although-works better for developers because it separates things using standard orthographic rules and does not require use of the Shift Key). – Veak Sep 06 '22 at 16:35\-and\_are both standard latex commands that you could redefine. Or you can make-a letter so it is allowed in csnames with\catcode \-=11 ` as shown above. – David Carlisle Sep 06 '22 at 16:39-. Could make-into a letter within a style file perhaps. Would the definition of a letter affect things like\alpha-\beta? – Veak Sep 06 '22 at 17:42-a letter. I had missed your small note about it. – Veak Sep 06 '22 at 17:50\makeatletterbut for-. – Veak Sep 06 '22 at 17:56-again in the style file after I am done with the definitions? – Veak Sep 06 '22 at 18:04@is reset after package definitions because the@named commands should never be used in documents. So if you want internal commands with-names you can reset-but if you want the-names to be accessible you obviously can not reset-. The constraint is not really about definitions but parsing: is\foo-barone token or 5. – David Carlisle Sep 06 '22 at 18:10\makeatletterbut call\makeatotheran the end ofmynames.sty– Veak Sep 06 '22 at 18:27\usepackageor\RequirePackageyou don't need to use\makeatletterand\makeatother, this is done for you by LaTeX. However, if you change the category code of any other character you'll have to reset it yourself at the end of your package (at least if you don't want to break any existing other package and/or document). – Skillmon Sep 06 '22 at 19:12(can now be part of a variable's name in Lisp. – Skillmon Sep 06 '22 at 19:13\alpha-\betawhich could be fixed by not allowing hyphens at the end of names. What other things would make the change problematic, besides changes to manuals? – Veak Sep 06 '22 at 19:45(is now valid in variable names in lisp. You might get lucky, because your code always used a space before and after(, but you just might not! – Skillmon Sep 06 '22 at 20:05\in key words (after the first), and requires termination of paths by;. Ortipa/tipauniwhich change your input to something pretty different. Orbeamerwith its syntax for overlays. There are packages that allow for functional programming, lambda calculus, etc. The thing about TeX is that you can tweak it until unrecognizable, but if you want others to use it as well you need to establish and keep standards. – Skillmon Sep 07 '22 at 07:52