Skip to content

Commit 19d4dd1

Browse files
authored
Fix rendering of custom latex commands in html spec (#455)
1 parent 30bb2cc commit 19d4dd1

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

source/conf/common_conf.py

+75
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,88 @@
143143
\newcommand{\diffgamma}{\operatorname{diff\_\gamma}}
144144
\newcommand{\diffbeta}{\operatorname{diff\_\beta}}
145145
\newcommand{\workspace}{\operatorname{workspace}}
146+
\newcommand{\srcshape}{\operatorname{src\_shape}}
146147
''',
147148
# Latex figure (float) alignment
148149
#
149150
# 'figure_align': 'htbp',
150151
'extraclassoptions': 'openany,oneside',
151152
}
152153

154+
imgmath_latex_preamble = r'''
155+
\newcommand{\src}{\operatorname{src}}
156+
\newcommand{\srclayer}{\operatorname{src\_layer}}
157+
\newcommand{\srciter}{\operatorname{src\_iter}}
158+
\newcommand{\srciterc}{\operatorname{src\_iter\_c}}
159+
\newcommand{\weights}{\operatorname{weights}}
160+
\newcommand{\weightslayer}{\operatorname{weights\_layer}}
161+
\newcommand{\weightsiter}{\operatorname{weights\_iter}}
162+
\newcommand{\weightspeephole}{\operatorname{weights\_peephole}}
163+
\newcommand{\weightsprojection}{\operatorname{weights\_projection}}
164+
\newcommand{\bias}{\operatorname{bias}}
165+
\newcommand{\dst}{\operatorname{dst}}
166+
\newcommand{\dstlayer}{\operatorname{dst\_layer}}
167+
\newcommand{\dstiter}{\operatorname{dst\_iter}}
168+
\newcommand{\dstiterc}{\operatorname{dst\_iter\_c}}
169+
\newcommand{\diffsrc}{\operatorname{diff\_src}}
170+
\newcommand{\diffsrclayer}{\operatorname{diff\_src\_layer}}
171+
\newcommand{\diffsrciter}{\operatorname{diff\_src\_iter}}
172+
\newcommand{\diffsrciterc}{\operatorname{diff\_src\_iter\_c}}
173+
\newcommand{\diffweights}{\operatorname{diff\_weights}}
174+
\newcommand{\diffweightslayer}{\operatorname{diff\_weights\_layer}}
175+
\newcommand{\diffweightsiter}{\operatorname{diff\_weights\_iter}}
176+
\newcommand{\diffweightspeephole}{\operatorname{diff\_weights\_peephole}}
177+
\newcommand{\diffweightsprojection}{\operatorname{diff\_weights\_projection}}
178+
\newcommand{\diffbias}{\operatorname{diff\_bias}}
179+
\newcommand{\diffdst}{\operatorname{diff\_dst}}
180+
\newcommand{\diffdstlayer}{\operatorname{diff\_dst\_layer}}
181+
\newcommand{\diffdstiter}{\operatorname{diff\_dst\_iter}}
182+
\newcommand{\diffdstiterc}{\operatorname{diff\_dst\_iter\_c}}
183+
\newcommand{\diffgamma}{\operatorname{diff\_\gamma}}
184+
\newcommand{\diffbeta}{\operatorname{diff\_\beta}}
185+
\newcommand{\workspace}{\operatorname{workspace}}
186+
\newcommand{\srcshape}{\operatorname{src\_shape}}
187+
'''
188+
189+
mathjax3_config = {
190+
'tex': {
191+
'macros': {
192+
'src': '\\operatorname{src}',
193+
'srclayer': '\\operatorname{src\\_layer}',
194+
'srciter': '\\operatorname{src\\_iter}',
195+
'srciterc': '\\operatorname{src\\_iter\\_c}',
196+
'weights': '\\operatorname{weights}',
197+
'weightslayer': '\\operatorname{weights\\_layer}',
198+
'weightsiter': '\\operatorname{weights\\_iter}',
199+
'weightspeephole': '\\operatorname{weights\\_peephole}',
200+
'weightsprojection': '\\operatorname{weights\\_projection}',
201+
'bias': '\\operatorname{bias}',
202+
'dst': '\\operatorname{dst}',
203+
'dstlayer': '\\operatorname{dst\\_layer}',
204+
'dstiter': '\\operatorname{dst\\_iter}',
205+
'dstiterc': '\\operatorname{dst\\_iter\\_c}',
206+
'diffsrc': '\\operatorname{diff\\_src}',
207+
'diffsrclayer': '\\operatorname{diff\\_src\\_layer}',
208+
'diffsrciter': '\\operatorname{diff\\_src\\_iter}',
209+
'diffsrciterc': '\\operatorname{diff\\_src\\_iter\\_c}',
210+
'diffweights': '\\operatorname{diff\\_weights}',
211+
'diffweightslayer': '\\operatorname{diff\\_weights\\_layer}',
212+
'diffweightsiter': '\\operatorname{diff\\_weights\\_iter}',
213+
'diffweightspeephole': '\\operatorname{diff\\_weights\\_peephole}',
214+
'diffweightsprojection': '\\operatorname{diff\\_weights\\_projection}', # noqa: E501
215+
'diffbias': '\\operatorname{diff\\_bias}',
216+
'diffdst': '\\operatorname{diff\\_dst}',
217+
'diffdstlayer': '\\operatorname{diff\\_dst\\_layer}',
218+
'diffdstiter': '\\operatorname{diff\\_dst\\_iter}',
219+
'diffdstiterc': '\\operatorname{diff\\_dst\\_iter\\_c}',
220+
'diffgamma': '\\operatorname{diff\\_\\gamma}',
221+
'diffbeta': '\\operatorname{diff\\_\\beta}',
222+
'workspace': '\\operatorname{workspace}',
223+
'srcshape': '\\operatorname{src\\_shape}',
224+
}
225+
}
226+
}
227+
153228

154229
def supsub_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
155230
node = docutils.nodes.superscript()

0 commit comments

Comments
 (0)