1

I've found thousands of posts and articles describing how to convert Latex documents into HTML or odt.

I tried everything but it seems my problem is peculiar.

I have 250 pages of compiled document which uses pdflatex to build. No problem at all.

A lot of pictures are produced exporting PDF+LaTeX in Inkscape, which produce a PDF + LaTeX file. Please, refer to: How to include SVG diagrams in LaTeX?

Other pictures are produced with octave in the same format. An empty graphics pdf. enter image description here

And a LaTeX file with labels info.

% Title: glps_renderer figur
% Creator: GL2PS 1.3.8, (C) 1999-2012 C. Geuzaine
% For: Octave
% CreationDate: Thu Mar  3 23:22:20 2016
\setlength{\unitlength}{1pt}
\begin{picture}(0,0)
\includegraphics{TensaoCorrente3_4kW-inc}
\end{picture}%
\begin{picture}(720,360)(0,0)
\fontsize{22}{0}
\selectfont\put(70,33.5081){\makebox(0,0)[t]{\textcolor[rgb]{0,0,0}{{0}}}}
\fontsize{22}{0}
\selectfont\put(179.245,33.5081){\makebox(0,0)[t]{\textcolor[rgb]{0,0,0}{{0.5}}}}
\end{picture}

I include the file using:

\begin{figure}
    \centering
    \resizebox{1\columnwidth}{!}{\input{img/TensaoCorrente3kW.tex}}
\end{figure}

The final result is:

enter image description here

When I try to use Latex I got many errors about bounding boxes in my figures which are pdf. No problem since pdflatex works fine.

The problem is that my professor only use Word to review my document, so I must convert my LaTeX document in to a readable word format.

Latex2HTML prints ugly pictures and equations.

So I tried htlatex which complains about same errors as latex compiler.

There is no way I can manually add bb option to every picture. I tried with 8 page paper and it took the whole day.

I don't think layout matters. I just need to convert my LaTeX to Word to be editable.

Please check the full example on the link. https://drive.google.com/file/d/0BwVP4AzXV_MqWExva0xIa0hkOGM/view?usp=sharing

  • the inkscape ones are presumably svg originally so that can go straight to the web page without conversion, similarly octave can i assume generate pngs that can be includes straight to the web, so you only need to convert the text of your latex file to html and then re-insert the images. – David Carlisle Mar 30 '16 at 20:02
  • Please, consider the post info, the images are pdf exported. In inkscape, it export a tex file with pdf embed. In octave the same way. I need tex4ht to convert pdf files as images. Please, refer to this post to understand. tex.stackexchange.com/questions/299836/… – Thales Maia Mar 31 '16 at 1:28
  • 1
    I find this question very confusing. What are you trying to convert to? Presumably, html2latex converts from HTLM to LaTeX, but the rest of the post suggests you're doing something else. Then you mention tracking changes which is something Word does, I believe, and Word. But how is this related to the rest? It isn't clear what the files exported by Inkscape are - you don't give an example, which would help people to understand. But Inkscape certainly can export SVG. – cfr Mar 31 '16 at 2:07
  • sorry, I edited to post for better understanding. – Thales Maia Mar 31 '16 at 13:12
  • Could you please provide full example including document preamble and links to sample images? – michal.h21 Mar 31 '16 at 13:32
1

Your sample file includes packages which are incompatible with tex4ht and which aren't useful in HTML mode anyway: transparent and pst-pdf. You can enable them only in PDF mode using:

\ifdefined\HCode\else
  \usepackage{pst-pdf}                        
  \usepackage{transparent} 
\fi

Your document can be compiled without these packages.

There is then question of image inclusion. You use two ways, first is direct PDF inclusion, the second is using TeX files with drawing commands exported by Inkscape.

The first way:

\begin{figure}%
 \centerline{\psfig{figure=img/fluxomagnetico_modelofabricado_axis_label.pdf,width=3.34in}}      
  \centering
        \caption{Final model of total flux density inside the electric generator}
  \label{fig:densidade_fluxo_maquina}           
\end{figure} 

use \includegraphics instead:

\begin{figure}%       
  \centering
  \includegraphics[width=1\columnwidth,bb=0 0 394 334]{img/fluxomagnetico_modelofabricado_axis_label.pdf}
  \caption{Final model of total flux density inside the electric generator}
  \label{fig:densidade_fluxo_maquina}           
\end{figure} 

The Inkscape generated files must be converted to PDF first and then included using \includegraphics as well. For each file create driver TeX file in this form (bencada.tex):

\documentclass[preview,margin=5pt]{standalone}

\usepackage{graphicx,xcolor}
\begin{document}    
\input{img/bancada_geracao.pdf_tex}
\end{document}

compile the driver files to pdf and include them in the main document:

% \input{img/bancada_geracao.pdf_tex}
\includegraphics{bencada.pdf}

You need now configure tex4ht to support PDF images. It can be done using a config file, mycfg.cfg for example:

\Preamble{xhtml}
\makeatletter
\Configure{graphics*}
   {pdf}
   {\Needs{"convert \csname Gin@base\endcsname.pdf  
                               \csname Gin@base\endcsname.png"}%  
\expandafter\getImgFile\expandafter{\Gin@base}{.png} 
\Picture[IMG]{\imgBase.png \ifx\noBoundingBox\UnDefined
   svg:width="\the\Gin@req@width"
   svg:height="\the\Gin@req@height"
\fi
 }
\special{t4ht+@File: \csname Gin@base\endcsname.png}
 }
  \makeatother
\begin{document}
\EndPreamble

you can compile your document now using

mk4ht oolatex Example mycfg

command. You may need to run it twice for the first time, because pdf files are converted in the first run and they will be used only in the consecutive runs.

Result opened in LibreOffice:

enter image description here

Full modified Example.tex:

\documentclass[twocolumn,10pt]{article}

\usepackage{epsfig} %% for loading postscript figures
\usepackage{graphicx}


\graphicspath{{img/}}
\ifdefined\HCode\else
  \usepackage{pst-pdf}
  \usepackage{transparent}
\fi
\usepackage{tikz}
\usepackage{amsmath}

\title{Example}


\begin{document}

\maketitle    


\section{Images}

Convert this document to word

\begin{figure}[h]
% \centerline{\psfig{figure=img/processo_termodinamico.pdf,width=3.34in}}
\centering
\includegraphics[width=1\columnwidth,bb=6 1 503 141]{img/processo_termodinamico.pdf}
\caption{}
\label{fig:processo_termodinamico}
\end{figure}

\begin{equation}
P_{Fe} = K_h B^2 f + K_c \left( Bf \right)^2 + K_e \left( Bf \right)^{3/2}
\label{eq:formula_perdas}
\end{equation}

\begin{figure}
    \centering
    % \resizebox{1\columnwidth}{!}{\input{img/BHCurve.tex}}
  \resizebox{1\columnwidth}{!}{\includegraphics{bh.pdf}}
    \caption{BH curve obtained from experimental evaluation from three different electrical steel materials at $1200~Hz$}
    \label{fig:BHCurve}
\end{figure}

\begin{figure}
%   \centerline{\psfig{figure=img/fluxomagnetico_modelofabricado_axis_label.pdf,width=3.34in}}

    \centering
    \includegraphics[width=1\columnwidth,bb=0 0 394 334]{img/fluxomagnetico_modelofabricado_axis_label.pdf}
    \caption{Final model of total flux density inside the electric generator}
    \label{fig:densidade_fluxo_maquina}
\end{figure}

\begin{table}[h]
    \caption{Total losses from three different electrical steel materials}
    \begin{center}
        \label{tab:machine_simulated}
        \begin{tabular}{c c}
             & \\ % put some space after the caption
            \hline
            Parameters & Value \\
            \hline
            Induced voltage & $220~V_{RMS}$ (16 coils) \\
            Ratted speed & $70000~RPM$\\
            Ratted current & $9.2~A$ \\
            Ratted power & $3.5~kW$ \\
            Stator length & $100~mm$ \\
            PM diameter & $21~mm$ \\
            \hline
        \end{tabular}
    \end{center}
\end{table}

\begin{equation} 
\dot{W}_{T} = \dot{m} \, c_p \, \eta_{T} \, T_{Tin} \left[ 1 - \left( \frac{P_{Tout}}{P_{Tin}} \right)^{\frac{\gamma -1}{\gamma }}  \right]
\label{eq:formula_potencia}
\end{equation}

\begin{figure}
    \centering
    \def\svgwidth{\columnwidth}
    % \input{img/bancada_geracao.pdf_tex}
    \includegraphics{bencada.pdf}
    \caption{Schematic representation of the electric power bench}
    \label{fig:bancada_geracao_eletrica}
\end{figure}

\end{document}
  • Adding bb manually is almost remaking the entire document, is there an alternative? – Thales Maia Mar 31 '16 at 22:21
  • Michal, you are very diligent! – Keks Dose Apr 2 '16 at 10:00
  • @KeksDose the Inkscape images have quite bad quality though :( the text is small and sometimes crop. The template for driver file needs some adjustments obviously – michal.h21 Apr 2 '16 at 10:13

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.