8

This is a tricky question.

Say I generate an image in gnuplot using the pslatex terminal:

gnuplot<plot.plt
latex dummy.tex
dvips -E -oimage.eps dummy

where 'plot.plt' contains:

set term pslatex
set output "graph.tex"
plot "..."

and where 'dummy.tex' reads:

\documentclass{article}
\pagestyle{empty}
\begin{document}
\input graph.tex
\end{document}

I then include this 'image.eps' file in a 'main.tex' document and compile it:

latex main
dvips main -o
ps2pdf main.ps

This generates a 'main.pdf' file.

I find it quite strange but I have noticed that when I open 'main.pdf', the document title which will appear in the menu bar of the document viewer I use (evince) will be 'graph.tex' rather than 'main.pdf'.

If I modify the .eps file with a text editor (say, vim), and replace the text 'graph.tex' by something else in the .eps file, then compile the latex file, this will change what appears in the menu bar when I open my 'main.pdf' file.

Here, I would like to know if there is also a way to change the document title which appears in this menu bar using latex, when I do not have figures. Supposedly there should be I believe. How can I do that?

Thank you in advance for your help.

2
  • Since this behaviour has nothing to do with evince I did an edit of your question and removed the according tag.
    – Speravir
    Mar 23 '12 at 18:28
  • I understand it should have nothing to do with evince; however, in another document viewer I use (Acrobat Reader) the title is "main.pdf", at least with the current version I have. This is why I explicitly mentioned evince.
    – Alex
    Mar 26 '12 at 13:50
5

This is caused by the following lines which gnuplot puts in graph.tex:

SDict begin [
  /Title (graph.tex)
  /Subject (gnuplot plot)
  /Creator (gnuplot 4.4 patchlevel 4)
  /Author (mait)
%  /Producer (gnuplot)
%  /Keywords ()
  /CreationDate (Fri Mar 23 16:20:26 2012)
  /DOCINFO pdfmark
end

I can't find anything in the gnuplot manual that prevents this behaviour, so I suggest editing the file and putting percentage symbols before /Title, /Subject, /Creator and /Author. Otherwise your figures are likely to interfere with other methods of inserting metadata into the pdf. Doing this manually is likely to be cumbersome if you have a lot of files, though.

EDIT

Gnuplot can issue system commands, so you can use a utility such as sed to automatically change the file graph.tex.

set term pslatex
set output "temp.tex"
plot x**2
set output #Closes the temporary output file.
!sed -e 's|/Title|%/Title|' -e 's|/Subject|%/Subject|' -e 's|/Creator|%/Creator|' -e 's|/Author|%/Author|' < temp.tex > graph.tex

I think this will work on any unix machine.

3
  • 1
    Yes, these are the lines I have been editing using vim. Note that I have noticed that only the last figure included in the document will be taken into account and needs to be edited this way. I am surprised that this is included in the .ps/.eps files, but only plays a role at the .pdf level.
    – Alex
    Mar 23 '12 at 16:56
  • 1
    All manner of wizardry can be performed using specials to insert instructions into the postscript code. I have edited my answer and added a means of automatically removing the offending lines. Mar 23 '12 at 17:42
  • In the postscript images one can also modify /SuppressPDFMark false def to true.
    – Friedrich
    Aug 6 '20 at 16:54
9

I don't see how this is related to gnuplot, but using

\usepackage{hyperref}

\hypersetup{pdftitle=foo,pdfdisplaydoctitle}

in your LaTeX document preamble might do what you want.

2
  • 1
    First of all: Thanks a lot, this indeed does the trick for files without images (quite tricky to explain but easily answered :)). For completeness, I have also checked what you have suggested for .tex files with images; however things remain as I have described here above in that case. I must say I do not really understand where this comes from, as everything comes in the form of .ps or .eps files: it's like this is hidden until I use ps2pdf.
    – Alex
    Mar 23 '12 at 16:42
  • 2
    @Stephan --- Gnuplot puts instructions in the postscript that influence the pdf metadata. Mar 23 '12 at 17:39
0

While dvipdfm seems to use the setting from hypersetup, ps2pdf seems to use values set in SDict. Just check the code in the postscript file. To overwrite the gnuplot setting from the figures, one can place this snippet at the end of the latex document:

% overwrite gnuplot pdfmark
% needed for ps2pdf
\special{ps:
SDict begin [
  /Title (foo)
  /Subject ()
  /Author (Albert Einstein)
  /Creator ()
%  /Producer (gnuplot)
%  /Keywords ()
  /CreationDate (Fri Jun 26 22:09:50 2020)
  /DOCINFO pdfmark
end
   }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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