我有这个Django模板,用于生成LaTeX文件。
\documentclass[11pt]{report}
\begin{document}
\begin{table}
\centering
\begin{tabular}{lcr}
\hline
{% for col in head %}
\textbf{ {{col}} }
{% if not forloop.last %}
&
{% endif %}
{% endfor %}
\\
\hline
{% for row in table %}
{% for cell in row %}
{% if not forloop.last %}
&
{% endif %}
{% endfor %}
\\
{% endfor %}
\hline
\end{tabular}
\caption{Simple Phonebook}
\label{tab:phonebook}
\end{table}
\end{document}
但是我的列数非常多,所以它们可以包含任何特殊字符。在生成PDF文件时出现错误。
我该如何转义所有列中的文本?
\textless
和\textgreater
之后应该还有一个空格。因为<a
变成了\textlessa
,所以我得到了“未定义的控制序列”的错误提示。 - minhle_r7r'\textless '
而不是r'\textless{}'
有什么原因吗? - Tyiloconv
进行排序,因为所有的键都是相同长度的。 - Mitar