简体   繁体   English

将带有unicode字符的字符串(例如→,∧,¬)转换为乳胶所示的字符串?

[英]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.

相关问题 如何在Windows cmd上将不支持的unicode字符打印为“?”而不是引发异常? - How to print unsupported unicode characters on Windows cmd as e.g. “?” instead of raising exception? Scrapy输出提供国际unicode字符(例如日语字符) - Scrapy output feed international unicode characters (e.g. Japanese chars) 根据另一个字符串列表(例如黑名单字符串)从字符串列表中每个元素的末尾删除字符 - Remove characters from the end of each element in a list of strings based on another list of strings (e.g. blacklist strings) 如何删除特定分隔符*内的字符串*中的特定字符,例如在括号内 - How to remove specific characters in a string *within specific delimiters*, e.g. within parentheses 正则表达式(Python),用于从&lt;和&gt;内部提取文本字符串-例如 <stringone><string-two> 等等 - Regular Expression (Python) to extract strings of text from inside of < and > - e.g. <stringone><string-two> etc 如何解决 flask 生产中的 Unicode 问题,例如 Ieeo? - How to solve Unicode problem in flask production e.g. Ieeo? 打印带有UTF-8编码字符的字符串,例如:“ \\ u00c5 \\ u009b \\” - Printing strings with UTF-8 encoded characters, e.g.: “\u00c5\u009b\” 和弦字典(Python)中特殊字符(例如#、/)的正则表达式问题 - Regex problems with special characters (e.g. #, /) in a chord dictionary (Python) 在python中将字符串转换为unicode字符 - Convert string to unicode characters in python 将字符串转换为带有特殊字符的unicode - Convert a string to unicode with special characters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM