0

I am writing a report which is often using the word "Sierpiński". Since I do not want to write \'n everytime, I made a custom macro:

\newcommand{\sierpinski}{Sierpi\'nski}

The problem occurs with white space (or lack there of) after \sierpinski. There is no white space. This is great when ending a sentence, or using punctuation, but a problem when another words is to follow.

I have made one work around:

\newcommand{\sierpinskiOption}[1]{Sierpi\'nski{#1}}

\newcommand{\sierpinski}{\sierpinskiOption{\ }}

Great! Now whenever I type \sierpinski, I get the correct word with a whitespace, and if I want to add punctuation, I can just specify that using \sierpinskiOptions{?}.

To me, this approach is very blunt. Is there a better approach? Perhaps a snippet of code which will check the next character to see if it is whitespace, or punctuation?

Dai Bowen
  • 6,117
misogrumpy
  • 153
  • 1
  • 1
    Just add \xspace at the end of it from the xspace package. – yannisl Mar 25 '24 at 01:43
  • 1
    @yannisl That appears to work! Thanks for the suggestion. I will have to look more at the xspace package to see all that it offers, but for now, I will let it rest. – misogrumpy Mar 25 '24 at 02:00
  • 3
  • 1
    What's the problem in directly writing Sierpiński? Maybe using the autocompletion features of the editor? – egreg Mar 25 '24 at 09:05
  • Probably typing ta backslash before an s is more comfortable than typing a backslash before a '. ;-) Nowadays LaTeX on 8-bit TeX-engines by default loads input with utf-8 option and XeTeX/LuaTeX have native support for utf-8-encoded input. So it is possible to type Sierpiński in your .tex-input-file, no control-sequences needed. – Ulrich Diez Mar 25 '24 at 18:34
  • How about giving \sierpinski an optional argument which by default is a space? Then, if you want punctuation, you type, e.g., \sierpinski[.](, which is weird, in my humble opinion). – Ulrich Diez Mar 25 '24 at 18:52
  • @UlrichDiez This would also work. But like you said, is unnatural, and definitely not the optimal solution in this case. But it might be for some other issue, so it's worth considering! – misogrumpy Mar 27 '24 at 14:56

0 Answers0