3

I've tried to convert an "article" (I'm still undergrad) from tex to docx extension.

Pandoc is giving me the following error each time I attempt to convert the file.

>pandoc meta.tex -o meta.docx

Error at "source" (line 40, column 1):
unexpected }
expecting \end{document}
};
^
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The original template (the Legrand Orange Book Template) can be found here --> http://www.latextemplates.com/template/the-legrand-orange-book
% Original author of the Legrand Orange Book Template:
% Mathias Legrand (legrand.mathias@gmail.com) with modifications by:
% Vel (vel@latextemplates.com)
% TEMPLATE EDITOR: Miguel Avila
% Original License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[11pt,fleqn]{book} % Default font size and left-justified equations

\usepackage[top=3cm,bottom=3cm,left=2.8cm,right=2.8cm,headsep=10pt,letterpaper]{geometry} % Page margins
\usepackage{xcolor} % Required for specifying colors by name
\definecolor{format-color}{HTML}{0b6969}
\definecolor{white}{HTML}{FFFFFF}

%----------------------------------------------------------------------------------------
%   STRUCTURE
%----------------------------------------------------------------------------------------
\input{structure} % Insert the commands.tex file which contains the majority of the structure behind the template

\begin{document}

\begingroup
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay]
\node (current page.north west) {
    \begin{tikzpicture}[remember picture,overlay]
        \fill[format-color](-2.8cm,3cm) rectangle (\paperwidth,-\paperheight);
    \end{tikzpicture}
}; % ERROR LINE, because the nested picture

\matrix [column sep=5mm,row sep=10cm] at (current page.center) {
    \node [fill=black,fill opacity=0.4,text opacity=1,inner sep=1cm] {
        \fontsize{56}{56}\centering\sffamily\parbox[c][][t]{\paperwidth} {
            \centering \textcolor{white}{\textbf{Portair}}\\ % Book title
            \textcolor{white}{\huge \textbf{Man in the middle}}
        }
    };\\
    \node [inner sep=0.5cm,fill=black,text opacity=1,fill opacity=0.4] {
        \fontsize{28}{28}\centering\bfseries\sffamily\parbox[c][][t]{\paperwidth} {
            \centering\textcolor{white}{\huge Miguel Avila}
        }
    }; % Author name
    \\
};
\end{tikzpicture}
\endgroup

\end{document}

This problem is repeated when I tried to use tex4ht

---Thank you beforehand---

  • 1
    Nesting tikzpictures is usually fraught with peril. But it does seem like you end the inner tikzpicture but not the outer (nor the document). Are you able to fix that? For that matter, if you no longer nest the tikzpictures, do things work out better? – Teepeemm Sep 18 at 19:52
  • @Teepeemm I put outside the nested picture and it worked, pandoc produced the file. However, is there any other way to do this? I have many other nested pictures. – Miguel Avila Sep 18 at 20:07
  • I cannot compile your sample even with pdflatex, it doesn't close tikzpicture and document environments. It also doesn't include TikZ package. I can compile your document to HTML with TeX4ht, using the dvisvgm4ht driver. It unfortunately doesn't work for the ODT output, because SVG images are not supported by ODT. – michal.h21 Sep 18 at 20:12
  • @michal.h21 I have updated the post so that there is a compilable version with the error. – Miguel Avila Sep 18 at 20:21
4

I can convert your document to HTML using TeX4ht and alternative driver for TikZ to SVG conversion.

The document just needs slight edit, in order to load the driver and to fix some mysterious error:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The original template (the Legrand Orange Book Template) can be found here --> http://www.latextemplates.com/template/the-legrand-orange-book
% Original author of the Legrand Orange Book Template:
% Mathias Legrand (legrand.mathias@gmail.com) with modifications by:
% Vel (vel@latextemplates.com)
% TEMPLATE EDITOR: Miguel Avila
% Original License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[11pt,fleqn]{book} % Default font size and left-justified equations

\usepackage[top=3cm,bottom=3cm,left=2.8cm,right=2.8cm,headsep=10pt,letterpaper]{geometry} % Page margins
\usepackage{xcolor} % Required for specifying colors by name
\definecolor{format-color}{HTML}{0b6969}
\definecolor{white}{HTML}{FFFFFF}

\makeatletter
\ifdefined\HCode
\def\pgfsysdriver{pgfsys-dvisvgm4ht.def}
\def\pgf@matrix@last@nextcell@options{}
\fi
\makeatother
%----------------------------------------------------------------------------------------
%   STRUCTURE
%----------------------------------------------------------------------------------------
% \input{structure} % Insert the commands.tex file which contains the majority of the structure behind the template
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begingroup
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay,ampersand replacement=\&]
\node (current page.north west) {
    \begin{tikzpicture}[remember picture,overlay]
        \fill[format-color](-2.8cm,3cm) rectangle (\paperwidth,-\paperheight);
    \end{tikzpicture}
}; % ERROR LINE, because the nested picture

\matrix [column sep=5mm,row sep=10cm] at (current page.center) {
    \node [fill=black,fill opacity=0.4,text opacity=1,inner sep=1cm] {
        \fontsize{56}{56}\centering\sffamily\parbox[c][][t]{\paperwidth} {
            \centering \textcolor{white}{\textbf{Portair}}\\ % Book title
            \textcolor{white}{\huge \textbf{Man in the middle}}
        }
    };\\
    \node [inner sep=0.5cm,fill=black,text opacity=1,fill opacity=0.4] {
        \fontsize{28}{28}\centering\bfseries\sffamily\parbox[c][][t]{\paperwidth} {
            \centering\textcolor{white}{\huge Miguel Avila}
        }
    }; % Author name
    \\
};
\end{tikzpicture}
\endgroup

\end{document}

The added code is this:

\makeatletter
\ifdefined\HCode
\def\pgfsysdriver{pgfsys-dvisvgm4ht.def}
\def\pgf@matrix@last@nextcell@options{}
\fi
\makeatother

It changes the TikZ driver and defines a control sequence that TikZ complain that isn't defined.

Here is the produced HTML file:

enter image description here

| improve this answer | |
  • Thank you so much, now I'll just handle the positions of my nodes directly. – Miguel Avila Sep 18 at 21: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.