In math mode, something like $if f x > 3 then 42 else y$
typesets to this:
Obviously, spacing is wrong here, and I need to correct manually:
$if \: f \: x > 3 \: then \: 42 \: else \: y$
typesets to
- Which is the correct amount of space to insert?
- Is there a way to automate this process, i.e. automatically insert a space between "words" separates by spaces in the source?
Best Answer
the spacing is the least of the problems, the letters are all wrong as well. The math italic font has wide side-bearings specifically so that adjacent letters do not look like letters forming a word but rather the usual mathematical use as implied multiplication of separate variables. To use a multi-letter identifier you need to use a text font, then inter-word spacing will automatically work as well, although you would need to use
\quad
or a similar space if embedding the text in math mode..or if you need to embed it in display math