Pandoc 无法处理 .tex 文档,因为 tikz 需要分号

Pandoc 无法处理 .tex 文档,因为 tikz 需要分号

我试图将一篇“文章”(我仍是本科生)转换为tex扩展docx名。

每次我尝试转换文件时,Pandoc 都会给我以下错误。

>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 ([email protected]) with modifications by:
% Vel ([email protected])
% 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}

当我尝试使用时,这个问题又出现了tex4ht

---提前谢谢您---

答案1

我可以使用 TeX4ht 将您的文档转换为 HTML,TikZ 到 SVG 转换的替代驱动程序

该文档只需稍加编辑,即可加载驱动程序并修复一些神秘的错误:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 ([email protected]) with modifications by:
% Vel ([email protected])
% 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}

添加的代码是这样的:

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

它改变了 TikZ 驱动程序并定义了 TikZ 抱怨未定义的控制序列。

以下是生成的 HTML 文件:

在此处输入图片描述

相关内容