Document Classesinsert file name in the document (header, footer)

Information and discussion about specific document classes and how to create your own document classes.
Cherepan
Posts: 9
Joined: Mon Sep 08, 2008 10:00 pm

insert file name in the document (header, footer)

Post by Cherepan »

Hi all,
I would like to have a name of the (source) file to be inserted in the dvi (and subsequentlt in pdf) output (perhaps without extention).

Is there any way to do it without modifing header or footer manually? :roll:

thanx

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

insert file name in the document (header, footer)

Post by localghost »

Cherepan wrote:[...] I would like to have a name of the (source) file to be inserted in the dvi (and subsequentlt in pdf) output (perhaps without extention). [...]
You just have to use the \jobname command to place that file name wherever you want.
Cherepan wrote:[...] Is there any way to do it without modifing header or footer manually? [...]
It seems to me like you are using the standard headers produced by \pagestyle{headings}. For an automation you should take a look at packages like fancyhdr or titlesec and create headers (and footers) with them.


Best regards and welcome to the board
Thorsten¹
Cherepan
Posts: 9
Joined: Mon Sep 08, 2008 10:00 pm

insert file name in the document (header, footer)

Post by Cherepan »

localghost wrote:You just have to use the \jobname command to place that file name wherever you want.
Could you please point out some literature how to use this commad. Quick Googling has not helped.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

insert file name in the document (header, footer)

Post by Stefan Kottwitz »

Hi Cherepan,

just use it without parameters, it will print the file name.
Here's one example without additional packages like fancyhdr:

Code: Select all

\documentclass[a4paper,10pt]{report}
\pagestyle{headings}
\begin{document}
\markboth{\jobname}{\jobname}
text
\newpage
text
\end{document}
Save it, give the file a name and compile, you will get the file name in the header.

Stefan
LaTeX.org admin
Cherepan
Posts: 9
Joined: Mon Sep 08, 2008 10:00 pm

insert file name in the document (header, footer)

Post by Cherepan »

Well, the result is a word "head" in the header. Am I missing something?
Stefan_K wrote:<...>
Save it, give the file a name and compile, <...>
Is the name that I should give differ from the one I save the file with? :roll:
User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

Re: insert file name in the document (header, footer)

Post by Stefan Kottwitz »

No, it's just the file name. Did you call it head.tex? In that case the result would be as desired.

Stefan
LaTeX.org admin
Cherepan
Posts: 9
Joined: Mon Sep 08, 2008 10:00 pm

insert file name in the document (header, footer)

Post by Cherepan »

Stefan_K wrote:Did you call it head.tex?
Stefan
Shame on me!!! I did!!! :oops: :oops:

Is there a way to make the file name to apper only on the first page?
Cherepan
Posts: 9
Joined: Mon Sep 08, 2008 10:00 pm

Re: insert file name in the document (header, footer)

Post by Cherepan »

Still, that does not work with "dissert" (a class for writing a thesis in Russian academia) document class at all. No name is printed.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

insert file name in the document (header, footer)

Post by Stefan Kottwitz »

Cherepan wrote:Is there a way to make the file name to apper only on the first page?
Just use \markboth{}{} on/before the second page.

Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

insert file name in the document (header, footer)

Post by Stefan Kottwitz »

Cherepan wrote:Still, that does not work with "dissert" (a class for writing a thesis in Russian academia) document class at all.
Perhaps we can help if you show us the class file, you could post dissert.cls as attachment here accompanied by a minimal working example.

Stefan
LaTeX.org admin
Post Reply