4

On the main site of TeX-LaTeX-StackExchange within comments1 you can use backticks `code` for writing code.

Seems this does not work when the piece of code has a leading sequence of spaces.

E.g., typing ` code` within a comment1 does not work out.

How to write code which has a leading sequence of spaces within a comment1?


1Comment—the kind of short message which you can write after clicking on "Add a comment".

4
  • Good question. Starting with   doesn't work either. Commented Apr 10, 2022 at 18:34
  • 1
    ​ abc xyz 123 Commented Apr 12, 2022 at 11:19
  • 1
    as above but it doesn't really start with a space (has zwsp at the start) so will mess up if someone cuts and pastes it to code) Commented Apr 12, 2022 at 11:20
  • also meta.stackexchange.com/questions/83522/… Commented Apr 12, 2022 at 11:24

1 Answer 1

6

You can use a zero width space (eg U+200b) at the start

​ abc xyz 123

That looks the nicest, but if you are expecting someone to copy the code as code it will have the unicode space character and give errors or warnings most likely.

So it is probably best to use a visible marker and tell the user to omit it as in

the code between the two |.     | abc xyz 123|

Note this is network wide (and been asked for and rejected on the network meta), eg

Preserving white space in comments

so nothing that can be changed here.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.