custom pylatex command 1

custom pylatex command

# You don't necessarily need to use the functions and classes that PyLaTeX provides. 
# You can add any arbitrary text or LaTeX code to your document as strings using the NoEscape wrapper

# Eg
doc.append(NoEscape(r'\begin{tabular}{ll}'))
doc.append(NoEscape(r'\Entry{abc}{123}\\'))
doc.append(NoEscape(r'\end{tabular}'))

Here is what the above code is Doing:
1. The NoEscape wrapper tells PyLaTeX that the string is LaTeX code and not Python code.
2. The r in front of the string tells Python that the string is a raw string.
This means that Python will not interpret backslashes as escape characters.
This is important because LaTeX uses backslashes for commands.

Similar Posts