测试CDM的时候出现了结果为nan的情况,如 #71 类似。查看了很多issue,尝试过多个ImageMagick版本,都无法解决问题。
后来从 #84 中获得启发。楼主通过重装pdflatex解决了问题,但具体如何重装不得而知。但至少知道了问题在pdflatex这里。于是我把生成的中间文件xx.tex和xx.log取出来看了,发现tex转pdf不成功在于\mathcolor未定义
各方查证\mathcolor为xcolor内定义的命令,但排除package的顺序和拼写问题之后,问题依然存在。于是想到用其他命令代替\mathcolor,即\textcolor,果然问题解决了。
解决方法:修改UniMERNet/cdm/modules/latex2bbox_color.py中的tabular_template、formular_template、formular_template_zh,各增加一行\let\mathcolor\textcolor,如下:
tabular_template = r"""
\documentclass[12pt]{article}
\usepackage[landscape]{geometry}
\usepackage{geometry}
\geometry{a<PaperSize>paper,scale=0.98}
\pagestyle{empty}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{upgreek}
\usepackage{amsmath}
\usepackage{xcolor}
\begin{document}
\makeatletter
\renewcommand*{\@textcolor}[3]{%%
\protect\leavevmode
\begingroup
\color#1{#2}#3%%
\endgroup
}
\let\mathcolor\textcolor
\makeatother
\begin{displaymath}
%s
\end{displaymath}
\end{document}
"""
formular_template = r"""
\documentclass[12pt]{article}
\usepackage[landscape]{geometry}
\usepackage{geometry}
\geometry{a<PaperSize>paper,scale=0.98}
\pagestyle{empty}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{upgreek}
\usepackage{amssymb}
\usepackage{xcolor}
\begin{document}
\makeatletter
\renewcommand*{\@textcolor}[3]{%%
\protect\leavevmode
\begingroup
\color#1{#2}#3%%
\endgroup
}
\let\mathcolor\textcolor
\makeatother
\begin{displaymath}
%s
\end{displaymath}
\end{document}
"""
formular_template_zh = r"""
\documentclass[12pt]{article}
\usepackage[landscape]{geometry}
\usepackage{geometry}
\geometry{a<PaperSize>paper,scale=0.98}
\pagestyle{empty}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{upgreek}
\usepackage{CJK}
\usepackage{amssymb}
\usepackage{xcolor}
\begin{document}
\makeatletter
\renewcommand*{\@textcolor}[3]{%%
\protect\leavevmode
\begingroup
\color#1{#2}#3%%
\endgroup
}
\let\mathcolor\textcolor
\makeatother
\begin{CJK}{UTF8}{gkai}
\begin{displaymath}
%s
\end{displaymath}
\end{CJK}
\end{document}
"""
PS: #84 的楼主在最后附上了修改pdflatex版本的方法,也可以参考试试。
测试CDM的时候出现了结果为nan的情况,如 #71 类似。查看了很多issue,尝试过多个ImageMagick版本,都无法解决问题。
后来从 #84 中获得启发。楼主通过重装pdflatex解决了问题,但具体如何重装不得而知。但至少知道了问题在pdflatex这里。于是我把生成的中间文件xx.tex和xx.log取出来看了,发现tex转pdf不成功在于
\mathcolor未定义各方查证
\mathcolor为xcolor内定义的命令,但排除package的顺序和拼写问题之后,问题依然存在。于是想到用其他命令代替\mathcolor,即\textcolor,果然问题解决了。解决方法:修改UniMERNet/cdm/modules/latex2bbox_color.py中的tabular_template、formular_template、formular_template_zh,各增加一行
\let\mathcolor\textcolor,如下:PS: #84 的楼主在最后附上了修改pdflatex版本的方法,也可以参考试试。