# 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 like 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 postprocess the Postscript® file with a sed script from the Makefile. This is done by a command such as

$(PSOBJECTS): \ %.ps: %.dvi Makefile dvips -o$*.ps $< sed -i 's/^%%Title:$</%%Title: This is a very long title in one line without line breaks/' $@ chmod a+r$@


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).

\RequirePackage{ifpdf}
\RequirePackage{ifxetex,ifluatex}
\newif\ifxetexorluatex
\ifxetex
\xetexorluatextrue
\else
\ifluatex
\xetexorluatextrue
\else
\xetexorluatexfalse
\fi
\fi

\documentclass{book}
\usepackage{relsize}
\newcommand{\bookTitleInOneLine}{This is a very long title in one line without line breaks}
\newcommand{\bookTitleWithLineBreaks}{This is a very long title\\occupying several lines\\with line breaks\\at meaningful positions}
\newcommand{\authorList}{John Doe, Sally Sixpack, Joe Bloggs, and John Smith}
\ifxetexorluatex
\usepackage[unicode,pdftitle={\bookTitleInOneLine},hidelinks,pdfauthor={\authorList}]{hyperref}%%% Setting basic meta data for the PDF
\else
\ifpdf
\usepackage[unicode,pdftitle={\bookTitleInOneLine},hidelinks,pdfauthor={\authorList}]{hyperref}%%% Setting basic meta data for the PDF
\else

• Do you want to see the title in the window title? Why don't you use then \usepackage[pdftitle=Title,pdfdisplaydoctitle=true]{hyperref}? – Ulrike Fischer Apr 3 at 16:06
• If you insert your line instead of \usepackage[unicode,hidelinks]{hyperref}, the title doesn't show up in the postscript file generated by latex+dvips, and the viewer gv still shows "main.dvi" in the window caption when viewing main.ps. – user49915 Apr 3 at 16:11