Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've got a LaTeX document that's build from many smaller files. When I'm editing text or formulas I usually look for some characteristic text and do something like:

find -name "*.tex" > t
grep -n 'text of interest' `cat t` | tee v
vim -q v

I see that there's a currfile package. I'd like to know if there's a way that I could use the \currfilename command in that package to stamp the margin with the filename (and/or path), or perhaps even just to generate a footnote.

EDIT: I found a way to do this in a standalone example, and that's posted below as a self-answer, which I initially thought to be sufficient. However, that answer used fancyhdr, and I'm using the classicthesis template which uses scrpage2, so a fancyhdr solution doesn't work. I've been able to make updates to classicthesis.sty to show the filenames in the chapter and section headers using \currfilepath, but would really like this to be a page level footer (one that I'd eventually make conditional on the drafting flag).

This is the scrpage2 section from classicthesis that I'd like to modify:

% ********************************************************************
% headlines
% ********************************************************************
\PassOptionsToPackage{automark}{scrpage2}
  \RequirePackage{scrpage2} % provides headers and footers (KOMA Script)
    \clearscrheadings
    \setheadsepline{0pt}
    \ifthenelse{\boolean{@nochapters}}%
        {\relax}%
        {\renewcommand{\chaptermark}[1]{\markboth{\spacedlowsmallcaps{#1}}{\spacedlowsmallcaps{#1}}}}
    \renewcommand{\sectionmark}[1]{\markright{\thesection\enspace\spacedlowsmallcaps{#1}}}
    \lehead{\mbox{\llap{\small\thepage\kern2em}\headmark\hfil}}
    \rohead{\mbox{\hfil{\headmark}\rlap{\small\kern2em\thepage}}}
    \renewcommand{\headfont}{\small}
%    \DeclareRobustCommand{\fixBothHeadlines}[2]{} % <--- ToDo
    % hack to get the content headlines right (thanks, Lorenzo!)
     \def\toc@heading{%
        \ifthenelse{\boolean{@nochapters}}%
        {\section*{\contentsname}}%nochapters
        {\chapter*{\contentsname}}%chapters
        \@mkboth{\spacedlowsmallcaps{\contentsname}}{\spacedlowsmallcaps{\contentsname}}}
share|improve this question
    
Are you adding the files using pdfpages? –  Werner May 24 '12 at 23:40
    
just a main .tex file that does various \input's and \include's of other .tex files. –  Peeter Joot May 24 '12 at 23:41
1  
While this does not answer your question you should really consider using the --synctex compile time option that is built into most of the editors. You simply right click on the output PDF and the actual source file that produced it opened. This will save you a lot of time. –  Peter Grill May 25 '12 at 0:06
    
Looks like I have to use TexWorks instead of acrobat to view the pdf for this to work. Thanks for the tip. It would be nice to be able to invoke other editors though. Do you know of a way to do that? –  Peeter Joot May 25 '12 at 1:53
1  
My LaTeX environment (Windows) is the Sublime Text 2 editor with the LaTeXTools package which allows a forward and inverse search with the SumatraPDF viewer. –  schlamar May 25 '12 at 7:35
show 3 more comments

1 Answer 1

up vote 10 down vote accepted

It's perhaps poor form to answer my own question, but I found a mechanism for this in the following question:

Add logo on each page.

The following example shows how things fit together

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{currfile}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{\currfilepath}
\renewcommand\headrulewidth{0pt}
\renewcommand\footrulewidth{0pt}
\begin{document}
\lipsum
\clearpage
\lipsum
\clearpage
\include{a/b/f1}
\include{a/b/f2}
\include{a/b/f3}
\include{a/b/f4}
\include{a/b/f5}
\include{a/b/f6}
\end{document}

where f1, f2, f3, ... all contain the following

\lipsum
\clearpage

As desired, I see a/b/f1.tex, a/b/f2.tex on all the \include generated pages (and the main .tex filename on the one that does the \include's).

share|improve this answer
    
It's perfectly acceptable to answer your own question – it might be a valuable source for others! You should also consider accepting it, eventually (maybe after waiting a couple of days for other answers.) –  Daniel May 25 '12 at 10:39
    
With currfile there should not be a reason to use \clearpage at the end of \include file. \include adds a \clearpage before and after the file content anyway and currfile uses filehook to change the file names after the last page is written. Did you experienced that differently? I'm the author of currfile and filehook so I would like to know if there are any issues. Originally I had similar code in my svn-multi package which required such an explicit \clearpage to get the header and footer of the last pages correct. –  Martin Scharrer May 26 '12 at 10:09
    
You are right. \clearpage is not required with any of the \include'd files. –  Peeter Joot May 26 '12 at 13:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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