In latex, one commonly uses CamelCase.
In my style file' I have
\newif\ifMath
\Mathfalse
Could these boolean flags be made to allow CamelCase, so the usage is
\newif\ifMath
\MathFalse
In latex, one commonly uses CamelCase.
In my style file' I have
\newif\ifMath
\Mathfalse
Could these boolean flags be made to allow CamelCase, so the usage is
\newif\ifMath
\MathFalse
You can define your own \NewIf macro:
\def\sdef#1{\expandafter\def\csname#1\endcsname}
\def\NewIf #1{\expandafter\NewIfA \string#1\relax #1}
\expandafter\def \expandafter\NewIfA \string \If#1\relax #2{%
\sdef{#1True}{\let#2=\iftrue}%
\sdef{#1False}{\let#2=\iffalse}%
\let#2=\iffalse
}
%test:
\NewIf\IfMath
\IfMath Yes\else No\fi
\MathTrue
\IfMath Yes\else No\fi
\MathFalse
\IfMath Yes\else No\fi
This macro allows you to use CamelCased \IfSomething too. The code above is inspired from \newif macro defined in OpTeX.
\Else and \Fi too. Beside this, in LaTeX I would prefer \IfMathTF{true}{false}, that is more consistent with the language.
– Ulrike Fischer
Oct 07 '22 at 19:04
\Else and \Fi for @UlrikeFischer:-)
– David Carlisle
Oct 07 '22 at 19:06
\IfMathTF was not the subject of the question. And if someone want to use \Else, \Fi then \let\Else=\else, \let\Fi=\fi is the solution. But I understand this question: TeX primitives and standard macros are lowercased and newly defined macros should be CamelCased for more explicit differences. Maybe this is the reason why OP needs such soulution.
– wipet
Oct 07 '22 at 19:15
\else is as readable as \Else. And \ifMath is as readable as \IfMath. Starting with uppercase is then not required. Whilst \MathTrue would be more readable than \Mathtrue.
– Veak
Oct 08 '22 at 18:42
To answer this question so the community bot doesn't bump every few months hopefully, if you want to assign a macro or value to be the same as another value or macro, use \let, as this answer by Norman Gray explains.
Simply going \let\MathFalse\Mathfalse should assign the value of \Mathfalse to \MathFalse. If you put this at the start of your style file then you should be able to use CamelCase throughout the rest of the .sty file by using \MathFalse in lieu of \Mathfalse.
you could do this but it breaks the language conventions so it is not a good idea:
Do not use \newif, simply do
\def\MathTrue{\let\ifMath\iftrue}
\def\MathFalse{\let\ifMath\iffalse}
\MathFalse
\newIf not be better because one knows it is not the language convention.
– Veak
Oct 08 '22 at 19:36
\newif with lowercase true and false.
– David Carlisle
Oct 08 '22 at 19:50
\galexIf so one knows it is a style setting. This will be defined in a style file galex.sty. Which will be used in documents using the style file.
– Veak
Oct 08 '22 at 20:01
\let\Mathfalse\MathFalse? – JamesT Oct 07 '22 at 18:15\if...you should follow the language conventions and use...trueand...falseto save confusing anyone looking at the code – David Carlisle Oct 07 '22 at 18:56expl3. – Veak Oct 08 '22 at 17:22texdoc interface3sec 9.2 or examples https://tex.stackexchange.com/search?q=%5Cbool_if – David Carlisle Oct 08 '22 at 17:44