0

I have this path "~/Library/Mobile Documents/com~apple~CloudDocs/Sync/160329_3DPP.bib". I cannot change that since the .bib file is synced through iCloud and updated frequently. I read that it is advised to use filename without spaces & special characters in latex. Isn't there any workaround yet (including packages that might handle this)?

I found some old & related topics that cannot provide a working solution, such as -

MRE:

. file

\documentclass[11pt]{article}       % use "amsart" instead of "article" for AMSLaTeX format
%\geometry{a4paper}                         % ... or a4paper or a5paper or letterpaper or... 
\usepackage[parfill]{parskip}           % Activate to begin paragraphs with an empty line rather than an indent
\usepackage[sort&compress]{natbib}
\usepackage[sectionbib]{chapterbib}%bibliography after each chapter
\usepackage{hyperref}

\title{Title} \author{massisenergy} %\date{} % Activate to display a given date or no date

\begin{document} Lorem Ipsum Odor \cite{2020FutomaThe-myth}

\bibliographystyle{unsrt} \bibliography{/Users/massisenergy/Library/Mobile Documents/com~apple~CloudDocs/Sync/160329_3DPP.bib}

  1. After running

. . . (/usr/local/texlive/2023/texmf-dist/tex/latex/base/ts1cmr.fd)

Package chapterbib Warning: The sectionbib option changes "\section *" to "\sec tion *" in \thebibliography on input line 285. (./2023_RS_AI.out) (./2023_RS_AI.out) [1] (./2023_RS_AI.bbl

Package natbib Warning: Empty `thebibliography' environment on input line 3. ) [2] (./2023_RS_AI.aux) ) Output written on 2023_RS_AI.pdf (2 pages). SyncTeX written on 2023_RS_AI.synctex.gz. Transcript written on 2023_RS_AI.log.

  1. After doing running

This is BibTeX, Version 0.99d (TeX Live 2023) The top-level auxiliary file: 2023_RS_AI.aux The style file: unsrt.bst White space in argument---line 18 of file 2023_RS_AI.aux : \bibdata{/Users/massisenergy/Library/Mobile : Documents/com\protect \unhbox \voidb@x \protect \penalty @M \ {}apple\protect \unhbox \voidb@x \protect \penalty @M \ {}CloudDocs/Sync/160329_3DPP.bib} I'm skipping whatever remains of this command I found no database files---while reading file 2023_RS_AI.aux Warning--I didn't find a database entry for "2020FutomaThe-myth" (There were 2 error messages)

  • 2
    It's sometimes the same using URLs with href. If the path is fix, and your lazy, you could try just to escape the special characters. That's how I manage it with my .bib file. To be honest, that's not a real solution but more of a lazy guy's workaround ;) – lukeflo Jun 24 '23 at 14:00
  • 4
    show a real example how you are using the path and which error you get. – Ulrike Fischer Jun 24 '23 at 14:12
  • @lukeflo, can you please elaborate more - any links or code snippet? – massisenergy Jun 24 '23 at 14:44
  • 1
    I've no experience using TeX with a Mac. Is the tilde ~ a verbatim character in Apple's path's? Using Latex it means a not breakable space character. So, there may be a misinterpretation of the path. Unfortunately, I'm not at home right now and only got a smartphone, so no chance to test it... – lukeflo Jun 24 '23 at 14:57
  • 1
    @massisenergy I think what lukeflo is suggesting is similar to this: \~/Library/Mobile Documents/com\~apple\~CloudDocs/Sync/160329\_3DPP.bib, as in put \ before the tildes and underscores to escape them. Try that and let us know how it goes – JamesT Jun 24 '23 at 17:12
  • What @JamesT writes is what i meant. But you may also have to escape the blank space between Mobile Documents. I don't know how Mac is handling those spaces, but since its also Unix based, I would suggest escaping the space would be better. – lukeflo Jun 24 '23 at 20:18
  • 3
    A possible solution is to set the environment variable BIBINPUTS to include the path to the directory with the bib file. Then in the .tex file, you just use \bibliography{160329_3DPP}. – John Collins Jun 24 '23 at 20:29
  • 1
    @lukeflo: Escaping the space won't help. The \bibliography macro is explicitly defined by latex to remove spaces in the \bibdata line it writes to the .aux file. If it did write them, bibtex would complain. – John Collins Jun 24 '23 at 20:42
  • 1
    @JohnCollins ok, didn't know that. But if it removes the space, it also can't find the path, right?. So your solution may be the best – lukeflo Jun 24 '23 at 20:45
  • 1
    @lukeflo: Correct. The \bibliography macro translates ~ to a complicated construct in the .aux file instead of leaving it as is. There should be a dirty trick to avoid that, but I don't know it. – John Collins Jun 24 '23 at 21:01
  • 3
    If the filename stays the same (but the content is updared) then you could also try to create a symlink to it, see https://tex.stackexchange.com/questions/337952/centralised-bib-file-on-mac for an example. – Marijn Jun 25 '23 at 08:53

1 Answers1

0

I wondered that this must be fairly common situation, like using multiple machines or using files which are updated & synced frequently. I'm just posting the answer from the comment by @Marijin in my question, using the following links -

This is an elegant solution, which not only solves my problem, but also provides ways to use other types of 'custom' files with LaTeX.

  1. Install & use the package: make-local-texmf
  2. Copy the directory/folder structure into my sync folder:

rsync -avh ~/Library/texmf ~/Library/Mobile\ Documents/com~apple~CloudDocs/Sync/texmf

  1. Move my bibliography file named 160329_MASTER.bib in the ~/Library/Mobile\ Documents/com~apple~CloudDocs/Sync/texmf/bibtex/bib/ folder.

  2. Delete the original folder created by make-local-texmf (otherwise running the following command will create another alias inside the ~/Library/texmf directory, like this ~/Library/texmf/texmf/)

  3. Symlink it using:

ln -s /Users/massisenergy/Library/Mobile\ Documents/com~apple~CloudDocs/Sync/texmf ~/Library/texmf

  1. MRE: + then + then twice this file:
\documentclass[11pt]{article}       % use "amsart" instead of "article" for AMSLaTeX format
%\geometry{a4paper}                         % ... or a4paper or a5paper or letterpaper or... 
\usepackage[parfill]{parskip}           % Activate to begin paragraphs with an empty line rather than an indent
\usepackage[sort&compress]{natbib}
\usepackage[sectionbib]{chapterbib}%bibliography after each chapter
\usepackage{hyperref}

\title{Title} \author{massisenergy} %\date{} % Activate to display a given date or no date

\begin{document} Lorem Ipsum Odor \cite{2020FutomaThe-myth}

\bibliographystyle{unsrt} \bibliography{MASTER_since160329.bib}

BONUS: I was pleasantly surprised to find that even I changed my bib file name (from to 160329_3DPP.bib to MASTER_since160329.bib), still opened the right file without any error when I relaunched it! Placing the .bib file in particular directory or symlinking it must be the reason I'm going to move my (.sty) files also to benefit from this...

Works like a charm Thanks to all the folks for your active participation & help

  • Of topic: the symlink and BIBINPUTS solutions suggested do work also on current Windiows (10/11). For windows users not at ease with console, as creation of symlink is tricky and env var not obvious to set/maintain, here is a simple workaround for names/paths containing spaces. Such names have a so called 8.3 alias, shown when doing dir /x on the console. E.g. Program Files can be replaced by PROGRA~1, Program Files (x86) by PROGRA~2, "Documents and settings byDOCUME~1and so on. Here~` is not placeholder for space nor home dIrectory but the real tilde character. – Jhor Jun 27 '23 at 08:43
  • Follow up of previous comment : the suggested "workaround" is usefully for many things as paths to TeX's executables interpreted by Windows but does NOT solve the OP TeX question as it unfortunately replaces the special character by a TeX's more problematic special ~ character. – Jhor Jun 27 '23 at 08:53
  • Indeed, it can be a whole different situation in Windows, compared to Unix (where command line interface is relatively easy to use). – massisenergy Jun 27 '23 at 14:00