# How to specify absolute paths [duplicate]

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 SwannSep 17 '18 at 15:19

• 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
• 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

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}


 TEXINPUTS=.:~/inputs:

where the trailing :` means to include the standard path.