1

I want to print the filename of the file that I'm calling (\input{file_name}). Clearly this includes the file contents but is there anyway to get the corresponding filename to print as well?

LordStryker
  • 1,036

1 Answers1

4

Do the following:

\begin{filecontents}{testfile.tex}
\begin{itemize}
\item first
\item second
\item third
\end{itemize}
\end{filecontents}
\documentclass[10pt,letterpaper]{article}
\newcommand\Inputa[1]{\texttt{#1}\par\nobreak\input{#1}} % filename before
\newcommand\Inputb[1]{\input{#1}\par\nobreak\texttt{#1}} % filename after
\begin{document}
\begin{center}
\textbf{Just a Demonstration}
\end{center}
\textbf{Filename before the input}

\Inputa{testfile} % Only need extension if not 'tex'

\textbf{Filename after the input}
\Inputb{testfile.tex}
\end{document}

Resulting in: enter image description here