Thursday, September 19, 2013

htlatex and pdflatex

I'm a big fan of the gnuplot tool that has an output terminal of pdflatex. This produces a pdf figure with an overlay of latex for beautiful results. Similarly, inkscape has an output format with pdf overlayed with latex.

I had a problem with htlatex. I use pdflatex and so everything is a pdf in my figures. My overlayed output from latex, with the file extension 'pdf_tex' uses an import file and then includegraphics at the bottom. htlatex complained it couldn't find the bounding box of my pdf file... which is reasonable enough as htlatex calls pdftex and apprently doesn't support including pdfs.

My solution was to include the following in my preamble. This allows the file to continue to work as previously with 'pdflatex' and when 'htlatex' is called, the convert program is called to generate a eps file.

 \graphicspath{{figures/}{results/}}

% call as:
% htlatex myfile.tex  "" "" "" -enable-write18
%
\makeatletter
\LetLtxMacro\latexincludegraphics\includegraphics
\@ifpackageloaded{tex4ht}
    {\renewcommand{\includegraphics}[2][]{%
        \immediate\write18{s=\Ginput@path; (IFS='{}'; for i in $s; do convert ${i}#2 ${i}#2.eps; done)}%
        \latexincludegraphics[#1]{#2.eps}}}
    {\renewcommand{\includegraphics}[2][]{\latexincludegraphics[#1]{#2}}}
\makeatother

Notes: 
  • you must call htlatex with -enable-write18 so it can execute commands in the shell.
  • you must include your graphics path setup before this gubbins.

Monday, July 29, 2013

scribus, latex, and bibtex

I've been playing with scribus. I managed to get bibtex working with my rendered frame and am recording the steps here.

1. create your latex frame, and include your bibliography stuff at the end of the document as you would for a normal document. i.e.

\bibliographystyle{abbrv}
\bibliography{refer}

2. Find out what the current temporary filename scribus is using for rendering is. It will be mentioned in the 'Program Messages' listing. The file will be in the $TEMP directory.

3. Jump into that directory and copy your bib file into the $TEMP directory.
4. Run bibtex on the temporary filename.
5. Run latex again, and again, using the 'Update' button on the Editor dialogue.



Thursday, April 18, 2013

I wanted to find the difference between accessed and modified epochs of a bunch of files. The incantation below gives you this number for each item in a directory:

$ stat -c "%X %Y %N" ~/* | awk '{diff = $1 - $2; print diff, $3}'
40449 '/home/home/my_cgi'
2173034 '/home/home/run_pvr.sh'
124618 '/home/home/tools'