2

I'm preparing a TeX document including PDF figures as an HTML document. The solution to this question works fairly well:

PDF image files and `htlatex`

However it does not handle image filenames with "(" or ")" characters, is there a way to include these in an HTML document?

2

The filenames needs to be escaped, because the special characters, such as "(" or ")" may cause problems in the conversion step, which is executed by system shell. Something like this happens on Linux:

System call: convert he(ll)o.pdf he(ll)o.png
sh: -c: line 0: syntax error near unexpected token ,,("
sh: -c: line 0: `convert he(ll)o.pdf he(ll)o.png'

MWE:

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\includegraphics{hello.pdf}
\includegraphics{"he(ll)o"}
\includegraphics{he(ll)o.pdf}
\end{document}

Fixed configuration file:

\Preamble{xhtml}
  \Configure{graphics*}  
         {pdf}  
         {\Needs{"convert '\csname Gin@base\endcsname.pdf'  
                               '\csname Gin@base\endcsname.png'"}%  
          \Picture[pict]{\csname Gin@base\endcsname.png}%  
          \special{t4ht+@File: \csname Gin@base\endcsname.png}
         }  
\DeclareGraphicsExtensions{.pdf,.png,.jpg,.eps}
\begin{document}
\EndPreamble

And the result:

enter image description here

  • Follow up query: Is this able to take PDFs in other directories? e.g., with \includegraphics{{"/home/tomkelly/directory/image".pdf}} – Tom Kelly May 11 '17 at 15:42

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.