From 19d4dd1fb0187158ad37365b584344368e184229 Mon Sep 17 00:00:00 2001 From: Mourad Gouicem Date: Thu, 10 Nov 2022 17:29:22 +0100 Subject: [PATCH] Fix rendering of custom latex commands in html spec (#455) --- source/conf/common_conf.py | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/source/conf/common_conf.py b/source/conf/common_conf.py index 3e2eb6f57b..6bd0f1d982 100644 --- a/source/conf/common_conf.py +++ b/source/conf/common_conf.py @@ -143,6 +143,7 @@ \newcommand{\diffgamma}{\operatorname{diff\_\gamma}} \newcommand{\diffbeta}{\operatorname{diff\_\beta}} \newcommand{\workspace}{\operatorname{workspace}} +\newcommand{\srcshape}{\operatorname{src\_shape}} ''', # Latex figure (float) alignment # @@ -150,6 +151,80 @@ 'extraclassoptions': 'openany,oneside', } +imgmath_latex_preamble = r''' +\newcommand{\src}{\operatorname{src}} +\newcommand{\srclayer}{\operatorname{src\_layer}} +\newcommand{\srciter}{\operatorname{src\_iter}} +\newcommand{\srciterc}{\operatorname{src\_iter\_c}} +\newcommand{\weights}{\operatorname{weights}} +\newcommand{\weightslayer}{\operatorname{weights\_layer}} +\newcommand{\weightsiter}{\operatorname{weights\_iter}} +\newcommand{\weightspeephole}{\operatorname{weights\_peephole}} +\newcommand{\weightsprojection}{\operatorname{weights\_projection}} +\newcommand{\bias}{\operatorname{bias}} +\newcommand{\dst}{\operatorname{dst}} +\newcommand{\dstlayer}{\operatorname{dst\_layer}} +\newcommand{\dstiter}{\operatorname{dst\_iter}} +\newcommand{\dstiterc}{\operatorname{dst\_iter\_c}} +\newcommand{\diffsrc}{\operatorname{diff\_src}} +\newcommand{\diffsrclayer}{\operatorname{diff\_src\_layer}} +\newcommand{\diffsrciter}{\operatorname{diff\_src\_iter}} +\newcommand{\diffsrciterc}{\operatorname{diff\_src\_iter\_c}} +\newcommand{\diffweights}{\operatorname{diff\_weights}} +\newcommand{\diffweightslayer}{\operatorname{diff\_weights\_layer}} +\newcommand{\diffweightsiter}{\operatorname{diff\_weights\_iter}} +\newcommand{\diffweightspeephole}{\operatorname{diff\_weights\_peephole}} +\newcommand{\diffweightsprojection}{\operatorname{diff\_weights\_projection}} +\newcommand{\diffbias}{\operatorname{diff\_bias}} +\newcommand{\diffdst}{\operatorname{diff\_dst}} +\newcommand{\diffdstlayer}{\operatorname{diff\_dst\_layer}} +\newcommand{\diffdstiter}{\operatorname{diff\_dst\_iter}} +\newcommand{\diffdstiterc}{\operatorname{diff\_dst\_iter\_c}} +\newcommand{\diffgamma}{\operatorname{diff\_\gamma}} +\newcommand{\diffbeta}{\operatorname{diff\_\beta}} +\newcommand{\workspace}{\operatorname{workspace}} +\newcommand{\srcshape}{\operatorname{src\_shape}} +''' + +mathjax3_config = { + 'tex': { + 'macros': { + 'src': '\\operatorname{src}', + 'srclayer': '\\operatorname{src\\_layer}', + 'srciter': '\\operatorname{src\\_iter}', + 'srciterc': '\\operatorname{src\\_iter\\_c}', + 'weights': '\\operatorname{weights}', + 'weightslayer': '\\operatorname{weights\\_layer}', + 'weightsiter': '\\operatorname{weights\\_iter}', + 'weightspeephole': '\\operatorname{weights\\_peephole}', + 'weightsprojection': '\\operatorname{weights\\_projection}', + 'bias': '\\operatorname{bias}', + 'dst': '\\operatorname{dst}', + 'dstlayer': '\\operatorname{dst\\_layer}', + 'dstiter': '\\operatorname{dst\\_iter}', + 'dstiterc': '\\operatorname{dst\\_iter\\_c}', + 'diffsrc': '\\operatorname{diff\\_src}', + 'diffsrclayer': '\\operatorname{diff\\_src\\_layer}', + 'diffsrciter': '\\operatorname{diff\\_src\\_iter}', + 'diffsrciterc': '\\operatorname{diff\\_src\\_iter\\_c}', + 'diffweights': '\\operatorname{diff\\_weights}', + 'diffweightslayer': '\\operatorname{diff\\_weights\\_layer}', + 'diffweightsiter': '\\operatorname{diff\\_weights\\_iter}', + 'diffweightspeephole': '\\operatorname{diff\\_weights\\_peephole}', + 'diffweightsprojection': '\\operatorname{diff\\_weights\\_projection}', # noqa: E501 + 'diffbias': '\\operatorname{diff\\_bias}', + 'diffdst': '\\operatorname{diff\\_dst}', + 'diffdstlayer': '\\operatorname{diff\\_dst\\_layer}', + 'diffdstiter': '\\operatorname{diff\\_dst\\_iter}', + 'diffdstiterc': '\\operatorname{diff\\_dst\\_iter\\_c}', + 'diffgamma': '\\operatorname{diff\\_\\gamma}', + 'diffbeta': '\\operatorname{diff\\_\\beta}', + 'workspace': '\\operatorname{workspace}', + 'srcshape': '\\operatorname{src\\_shape}', + } + } +} + def supsub_role(name, rawtext, text, lineno, inliner, options={}, content=[]): node = docutils.nodes.superscript()