Home Comments Thread
New Thread

Don't Use Spaces or Underscores in File Paths; Use Dashes Instead - especially when you are working with LaTeX | /en/2018/03/space-pain/

yihui yihui 2022-12-17 03:11:03

Don't Use Spaces or Underscores in File Paths; Use Dashes Instead - especially when you are working with LaTeX

https://yihui.org/en/2018/03/space-pain/

4 Comments

giscus-bot giscus-bot 2022-12-17 03:11:04
Guest *Mingshuo Ji* @ 2018-03-15 19:17:41 originally posted:

Ha, I have been using "_" for a long time, looks I will need to change it to "-" now.

giscus-bot giscus-bot 2022-12-17 03:11:06
Guest *Nicholas Tierney* @ 2018-03-15 23:33:35 originally posted:

Totally agreed about the dashes! I actually switched to using dashes because I'm pretty sure I read in the knitr documentation that is what you recommended.

I now try and use dashes for all my files, as it also has the handy feature of being able to tab through word-by-word, whereas when you use underscore it skips_right_to_the_end_of_the_text.

giscus-bot giscus-bot 2022-12-17 03:11:12
Guest *Mara* @ 2018-03-19 12:34:11 originally posted:

Oh, interesting. I'm a diehard underscorer, but that's quite an appealing feature…

giscus-bot giscus-bot 2022-12-17 03:11:07
Guest *Mark van der Loo* @ 2018-03-16 10:08:33 originally posted:

Underscores never causes problems in file names. You only need to escape them in LaTeX if you mention a string literal with _. I like Jenny Brian's advice: use _ for separating metadata types and - for spaces. But whatever you do NEVER EVER EVER USE SPACES. Also start filenames with an ISO date (i.e. 20180316)

yihui yihui 2022-12-17 03:11:09

Here is the issue that made me write this post: rstudio/bookdown#550 The underscore caused an unexpected issue to bibtex, which I don't fully understand.

Originally posted on 2018-03-16 14:05:29

giscus-bot giscus-bot 2022-12-17 03:11:10
Guest *Mark van der Loo* @ 2018-03-16 14:24:01 originally posted:

That's probably because of how the yaml header gets parsed. You can put

bibliography{my_file}

in a LaTeX file with no problems (just double-checked it with XeLaTeX)

yihui yihui 2022-12-17 03:11:11

Ha. Interesting. Thanks for testing it!

Originally posted on 2018-03-16 14:28:58

giscus-bot giscus-bot 2022-12-17 03:11:13
Guest *yo* @ 2019-02-01 09:37:22 originally posted:

the iso date is 2018-03-16 ;)

giscus-bot giscus-bot 2022-12-17 03:11:08
Guest *vsoch* @ 2018-03-18 00:51:59 originally posted:

Dashes (-) will break Python. Underscores are usually the way to go, if some kind of "this is a different word" strategy that isn't using CamelCase is warranted.

Sign in to join the discussion

Sign in with GitHub