0

This question already has an answer here:

I input a file inp.txt using its path relative to the directory containing the main.tex file and where I will run pdflatex:

\documentclass{article}
\begin{document}
    \input{../inputs/inp.txt}
\end{document}

Is there a way to specify the absolute path of inp.txt, e.g. ~/inputs/inp.txt?

Since I am looking for a general solution to include \includegraphics, \input and \include files I try to use TEXINPUTS and modify my script:

\documentclass{article}
\begin{document}
    \input{inp.txt}
\end{document}

When I run

TEXINPUTS=~/inputs pdflatex main.tex

it turns out I have changed my working directory producing the error message:

! I can't find file `filepath.tex'.

Adding multiple paths TEXINPUTS=~/inputs:. produces other problems.

Is there a simple and concise solution?

marked as duplicate by Stefan Pinnow, Phelype Oleinik, siracusa, dexteritas, Andrew Swann Sep 17 '18 at 15:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    just specify the path, eg /users/someone/inputs/inp.txt if you want to use ~ use \string~ otherwise it means nobreak space. – David Carlisle Sep 17 '18 at 11:14
  • 3
    your TEXINPUTS setting has not changed the working directory but has removed all the standard directories from the path, you need a trailing : – David Carlisle Sep 17 '18 at 11:21
6

Just specify the path, eg

\input{/users/someone/inputs/inp.txt}

if you want to use ~ use \string~ otherwise it means nobreak space.

\input{\string~/inputs/inp.txt}

(added after edit to question)

Your TEXINPUTS setting should be

 TEXINPUTS=.:~/inputs:

where the trailing : means to include the standard path.

Not the answer you're looking for? Browse other questions tagged or ask your own question.