# Which file is really used with \input command

how to know which file is included when we use the command `\input` if we have many files with the same name in various directories

If you look in the log file the full path of the input file is shown, which tells you after the fact which file is input.

If you want to control in advance which file is input then you need to look at TEXINPUTS this may be set as an environment variable or (more usually these days) as a setting in a `texmf.cnf` file.

You can use `kpsexpand` to see the current value.

For me

``````kpsexpand '\$TEXINPUTS'
``````

produces

``````.:
{/home/davidc/.texlive2015/texmf-config,
/home/davidc/.texlive2015/texmf-var,
/home/davidc/texmf,
!!/usr/local/texlive/2015/texmf-config,
!!/usr/local/texlive/2015/texmf-var,
!!/usr/local/texlive/texmf-local,
!!/usr/local/texlive/2015/texmf-dist}/tex/{kpsewhich,generic,}//
``````

so each `:` segment is searched in order so the current directory (`.`) is first then each of the directories is searched as listed, paths ending `//` are recursively searched in any subdirectory, paths beginning with `!!` the actual file system is not searched (which would be slow) but the pre-made filelist (`texhash` or `mktexlsr` commands) is consulted the form `{kpsewhich,generic,}` at the end means that for latex for example `tex/latex` is searched before `tex/generic` which is searched before (the whole of) `tex`.

As far as I know,

``````\input{filename}
``````

inserts the file 'filename' -- if it does not exist it automatically looks for 'filename.tex'

You can use

``````\input{filename.tex}
``````

to erase any ambiguities.

• this does not answer the question, which is which file is input if there are multiple files of that name. – David Carlisle Jan 28 '16 at 13:53
• I see. The question has been edited and is now much more specific. – HATEthePLOT Jan 28 '16 at 14:04