I've made a function/command for use mid-sentence, but it adds spaces everywhere it's inserted. Is there a way to flag it so it doesn't make them?
Code:
\def \testvar{0}
\newcommand{\test} {
\ifnum \testvar=1 {
test0
}
\else {
test1
}
}
Inside document:
aaaa \test aaaa
Output:
aaaa test1 aaaa
Wanted output:
aaaa test1 aaaa
%to the end of each line in the definition. See https://tex.stackexchange.com/questions/7453/what-is-the-use-of-percent-signs-at-the-end-of-lines – Steven B. Segletes Feb 24 '20 at 20:091in the ifnum test) – David Carlisle Feb 24 '20 at 20:11aaaa \test{} aaaaoraaaa \test\ aaaaor usexspace, – Phelype Oleinik Feb 24 '20 at 20:12- It makes me unable to fold the function - some functions cover the whole screen, I can't work like that
- It doesn't look like it's the intended way of doing this - I'd prefer to use the TeX components properly
– Random Persson Feb 24 '20 at 20:55%to break a definition into multiple lines without the introduction of space is to not break the definition into multiple lines and keep typing until you hit the}. The treatment of line-ends by TeX is quite well known and documented. The answer at the linked question does a good job of explaining it. – Steven B. Segletes Feb 24 '20 at 21:00\else,\ifnum, and\fi, no%is needed to suppress spurious spaces. – Steven B. Segletes Feb 24 '20 at 21:15\ifnum #1=0{the extra space is coming from the newline after{but in that case you do not want the{there at all they are just putting groups around your\paragraphcommand, which is not normally wanted, so you could delete the{which will also remove the spurious space – David Carlisle Feb 24 '20 at 21:24\refstepcounter{zadcounterA}SPACE{so additional spaces in the output. – David Carlisle Feb 24 '20 at 21:27