## LaTeX forum ⇒ General ⇒ How to set the title of the generated Postscript® file from within the source LaTeX file?

LaTeX specific issues not fitting into one of the other forums of this category.
user49915
Posts: 35
Joined: Wed Apr 17, 2019 12:51 pm

### How to set the title of the generated Postscript® file from within the source LaTeX file?

Every once in a while I have to compile source .tex files into .ps files. (The reasons may differ: e.g., due to certain amount of pstricks-heavy legacy code, or issues of some old-printer–CUPS-filters that suddently do not process submitted PDFs properly, or an IEEE journal still requesting a Postscript file from me, etc.) These Postscript® files have a title comment which usually looks as follows:

%%Title: main.dvi

where "main" comes from my input file "main.tex". However, I usually wish to have something more meaningful there that the viewers such as gv or evince would parse and display properly in their window captions and when being asked about the file properties.

Therefore, after running latex+dvips I usually postprocess the Postscript® file with a sed script from the Makefile. The downside of this approach is that now the title is present twice: inside the tex file and inside the Makefile. So, when you change the title at one place, you often forget to change the title at another place.

I'm wondering whether it is possible to set the title for the Postscript® file from within the tex file (which will be then the only place then where the title will be set) by some clever command(s).


user22741
Posts: 35
Joined: Fri Nov 09, 2018 12:03 pm

user22741
Posts: 35
Joined: Fri Nov 09, 2018 12:03 pm
The name shown in the .ps comments is utterly unrelated to the tex document. It get added from dvips. If you want to change it, rename the .dvi before converting it to .ps

Example:

latex main.texmv main.dvi leon.dvidvips leon.dvi leon.ps

user49915
Posts: 35
Joined: Wed Apr 17, 2019 12:51 pm
user22741 wrote:The name shown in the .ps comments is utterly unrelated to the tex document. It get added from dvips. If you want to change it, rename the .dvi before converting it to .ps

This approach has the same drawback: the title is present at two different places (in the tex file and in the file system). Unfortunately, it is even worse than postprocessing with sed, since file systems typically restrict the character set that can be used in the file names.

user22741
Posts: 35
Joined: Fri Nov 09, 2018 12:03 pm
Use a reasonable name for your tex file (no crazy letters that your systems disallows for a good reason), set the title in the hyperref options to the same with pdftitle={\jobname} and the comment in the ps file will be correct automatically

If you insist on a jobname different from your file name, compile with latex --jobname=foo main

user49915
Posts: 35
Joined: Wed Apr 17, 2019 12:51 pm
user22741 wrote:Use a reasonable name for your tex file (no crazy letters that your systems disallows for a good reason)

Of course.
Paper titles such as "The wildcards * and ? are considered harmful: a saga on input/output" would lead to file names such as "The wildcards * and ? are considered harmful: a saga on input/output.tex" which I believe to be illegal on (ex)FAT or NTFS.