[英]Convert string with unicode characters e.g. →,∧,¬ into strings illustrated in latex?
Is their a way or method in python which is able to convert strings in which logical symbols occur as unicode characters into latex code:他们是python中的一种方式或方法,它能够将逻辑符号作为unicode字符出现的字符串转换为乳胶代码:
means:方法:
str1 = '¬q→ ¬p→q'
into进入
str1_tex = '$\neg q\rightarrow \neg p\rightharrow q'
or或者
str2 = 'q∧ q'
into进入
str2_tex = '$q \wedge q$'
That is possible.这是可能的。 Check out the following repo: https://github.com/mennucc/unicode2latex查看以下存储库: https ://github.com/mennucc/unicode2latex
Optionally you can define everything yourself by using a dictionary.或者,您可以使用字典自己定义所有内容。
You could safe yourself the hassle to convert your strings if you compile with an unicode-aware engine like lualatex or xelatex:如果您使用 lualatex 或 xelatex 等支持 unicode 的引擎进行编译,则可以避免转换字符串的麻烦:
% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{unicode-math}
\begin{document}
\[
¬q→ ¬p→q
\]
\[
\neg q\rightarrow \neg p\rightarrow q
\]
\end{document}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.