TextMobject/TexMobject does not allow properly override of template_tex_file_body
- Lingua principale
- Python
- Stelle
- 93.8k
- Fork
- 7.7k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
```
TEMPLATE_TEXT_FILE_BODY_TABULAR = TEMPLATE_TEXT_FILE_BODY.replace("\\usepackage[english]{babel}\n", "\\usepackage[english]{babel}\n\\usepackage{caption}\n\\usepackage{multicol}\n\\usepackage{multirow}\n")
tblBitwiseAnd = r"""
\begin{table}
\centering
\begin{tabular}{|c|l|c|l|c|}
\hline
\textbf{$a$} & \multirow{5}{*}{$\&$} & \textbf{$b$} & \multirow{5}{*}{$=$} & \textbf{$a\& b$} \\ \cline{1-1} \cline{3-3} \cline{5-5}
0 & & 0 & & 0 \\ \cline{1-1} \cline{3-3} \cline{5-5}
0 & & 1 & & 0 \\ \cline{1-1} \cline{3-3} \cline{5-5}
1 & & 0 & & 0 \\ \cline{1-1} \cline{3-3} \cline{5-5}
1 & & 1 & & 1 \\ \hline
\end{tabular}
\caption*{Bitwise And/Multiplication\\($a\& b\equiv a*b$)}
\end{table}
"""
tbl = TextMobject(tblBitwiseAnd, template_tex_file_body=TEMPLATE_TEXT_FILE_BODY_TABULAR)
```
However since TextMobject defines CONFIG as does its base class TexMobject, and the further base class SingleStringTexMobject also defines it, TexMobject digest_config does not cause it to load into self.CONFIG and then when TexMobject calls break_up_by_substrings which uses self.CONFIG to initialize further SingleStringTexMobject objects, they will not use the correct template.
It looks like any reference to self.CONFIG would be less than ideal because the object dictionary is updated based on a combination of things, and self.CONFIG is basically only supposed to be used in the constructor.
The fact that break_up_by_substrings references certainly looks like a bug.
Workaround:
```
o = TextMobject.CONFIG.copy()
o['template_tex_file_body']=TEMPLATE_TEXT_FILE_BODY_TABULAR
tbl = TextMobject(tblBitwiseAnd, CONFIG=o, template_tex_file_body=TEMPLATE_TEXT_FILE_BODY_TABULAR)
```
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.