Montag, 28. April 2014

make gnuplot produce a latex standalone document

gnuplot has a view very good terminals including the epslatex-terminal the only backdraw which i had recently was that the terminal produces either:
- a latex file which can be included in the latex-document
or
- a latex-document which produces a pdf with the minimal-documentclass
but it does not produce a document which can be used via includestandalone.

But now I found a way to do it.

1.  create example with epslatex terminal


set terminal epslatex
set output "test.tex"
plot sin(x)
set output

2. Add preamble for standalone figure and add \end{document}

Add at the beginning of test.tex:
 \documentclass{standalone}
\usepackage{graphicx}
\begin{document}

Add at the end of test.tex
\end{document}

PS: I also wrote a gnuplot script doing all of this:

epslatexterm(name, xsize, ysize, gnuplotcommand) = sprintf('\
name="%s";\
file=name.".tex";\
set terminal epslatex size %s, %s;\
%s;\
set output name.".tex";  \
replot; \
unset output;\
eval bash(''echo \" \\\\begin{document}            \" |cat - ''.file.'' > tmp    '');\
eval bash(''echo \" \\\\usepackage{graphicx}       \" |cat - tmp      > tmp2   '');\
eval bash(''echo \" \\\\documentclass{standalone}  \" |cat - tmp2     > tmp    '');\
eval bash(''echo \" \\\\end{document}              \" |cat tmp -      > tmp2   '');\
eval bash("sed ''s/".name."/".name."-inc/g'' tmp2 > ".file  );\
eval bash(''mv ''.name.''.eps ''.name.''-inc.eps'');\
eval bash(''rm tmp tmp2 -f'');\
set terminal wxt; \
',name,xsize,ysize,gnuplotcommand)

Mittwoch, 9. April 2014

set password for a pdf-file

To add a password to a pdf you can simply use pdftk and have it add a password as follows:

pdftk original.pdf output new.pdf user_pw PROMPT

You will get a prompt asking for the password, which in turns will be added to your pdf-file.