My boss insists that every document I give him must have the file path to that document at the bottom of the last page. No problem with MS Word, but I don't have a clue how to do this in Latex. At the moment, I am putting a footnote at the end of the document to do this. I thought about special footers but I don't know how to change the footer of just the last page.
Asked
Active
Viewed 619 times
2 Answers
5
To improve the solution we need to know what class you are using and if one side or two side printing.
\documentclass{report}
\usepackage{lipsum} % dummy text
\makeatletter
\def\fullpath{\begingroup\everyeof{\noexpand}\@sanitize
\edef\x{\@@input|"find `pwd` -name \jobname.tex" }%
\edef\x{\endgroup\noexpand\zap@space\x\noexpand\@empty}\x}
\def\ps@path{
\def\@oddfoot{\texttt{\fullpath}\hfil\thepage}
\def\@evenfoot{\texttt{\fullpath}\hfil\thepage}
}
\makeatother
\AtEndDocument{\thispagestyle{path}}
\begin{document}
\lipsum[1-10]
\end{document}
ps: \fullpath command taken from an @egreg post and requires pdflatex -shell-escape.
-
The document class is article. I am using one-sided printing. – Steven Alexis Gregory Feb 26 '15 at 19:18
-
Also, you need to tell us where you want the page number on the last page. You have 3 positions (left, center and right) on header/footer. What you want on those positions? – Sigur Feb 26 '15 at 19:24
-
I figure centered page number with the file path centered below it. – Steven Alexis Gregory Feb 26 '15 at 19:34
-
@StevenGregory, did you test my code?m Did it work? I guess that it works on Linux since it uses bash commands. Are you using Windows? – Sigur Feb 26 '15 at 19:39
-
I'm using the Latex provided by Overleaf on a Windows 7 OS. I'm going to try your code now. Sorry for the delay. – Steven Alexis Gregory Feb 26 '15 at 23:04
-
1It will not work on Windows. – Sigur Feb 26 '15 at 23:08
-1
\documentclass{report}
\usepackage{lipsum} % dummy text
\makeatletter
\def\ps@path{
\def\@oddfoot{\texttt{text that I want to be here}\hfil\thepage}
\def\@evenfoot{\texttt{text that I want to be here}\hfil\thepage}
}
\makeatother
\AtEndDocument{\thispagestyle{path}}
\title{how to put text at the bottom of the last page}
\begin{document}
\lipsum[1-10]
\end{document}
-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Martin Schröder Feb 27 '15 at 17:23
-
-
@Christian, It's an answer. It's an answer. More or less, it is what I ended up using. – Steven Alexis Gregory Feb 27 '15 at 20:51
-
It would be great if there would be some words of explanation to the answer. Code-only answers are generally not the best presentation, so your answer would be a better example with some words added, motivating others to do the same. – Stefan Kottwitz Mar 10 '15 at 16:17
-
@Stefan, But I don't know what the code is doing. I just played with the original solution until it did what I wanted it to do. – Steven Alexis Gregory Mar 11 '15 at 13:08
-
Normally, I delete downvoted answers. But, since this code actually does what I want it to do, I am going to leave it here. – Steven Alexis Gregory May 11 '15 at 20:59