简体   繁体   English

LaTeX:美元符号与 \\( \\)

[英]LaTeX: dollar sign vs \( \)

Is there any reason to prefer the syntax \\(myformula\\) to the usual $myformula$ in LaTeX?有什么理由更喜欢语法\\(myformula\\)$myformula$ LaTeX 中通常的$myformula$吗?

Edit : The same question was asked, and answered, on tex.stackexchange .编辑:在tex.stackexchange上提出并回答了同样的问题。

LaTeX can catch nesting errors with \\( ... \\) but in practise there's no real advantage to using them over $ ... $ . LaTeX 可以用\\( ... \\)捕获嵌套错误,但实际上使用它们比$ ... $没有真正的优势。 If you do use \\( ... \\) , then make sure to load the fixltx2e package to make them robust (ie, eg, usable in captions and section headings).如果您确实使用了\\( ... \\) ,那么请确保加载fixltx2e包以使其健壮(即,例如,可用于标题和章节标题)。

As others have said, on the other hand, \\[ ... \\] should be used instead of $$ ... $$ .正如其他人所说,另一方面,应该使用\\[ ... \\]而不是$$ ... $$

I read in [1] (German text), that the use of $$ ... $$ leads to inconsistencies in vertical spaces before and after the formula, which shouldn't happen with [ ... ] .我在 [1](德语文本)中读到,使用$$ ... $$会导致公式前后垂直空间不一致,而[ ... ]不应该发生这种情况。

[1] ftp://ftp.dante.de/tex-archive/info/l2tabu/german/l2tabu.pdf (Section 1.6) [1] ftp://ftp.dante.de/tex-archive/info/l2tabu/german/l2tabu.pdf (第 1.6 节)

Only that some editors can't balance $ signs, where they can balance the brackets in the \\(\\) form.只是有些编辑器不能平衡 $ 符号,他们可以平衡\\(\\)形式的括号。 If you have a good editor (and with emacs and auctex mode out there, who doesn't?), then it's not an issue.如果你有一个好的编辑器(并且有 emacs 和 auctex 模式,谁没有?),那么这不是问题。

I use $formula$ and $$formula$$ .我使用$formula$$$formula$$ But sometimes you need to catch the end of the math mode.但有时你需要赶上数学模式的结束。 The thing is that you can catch the begin of the math mode using \\everymath or \\everydisplay :问题是您可以使用\\everymath\\everydisplay捕捉数学模式的开始:

\everymath{\color{red}}

Unfortunately you can not catch end of the math mode.不幸的是你不能赶上数学模式的结束。 But if you use \\( and \\) you can redefine \\) :但是如果你使用\\(\\)你可以重新定义\\)

\let\endmath\)% Save \)
\def\){\preendmath \endmath \postendmath}% Override
\def\preendmath{\,(*)}% For example
\def\postendmath{}% Any stuff

我相信$...$在技​​术上不是标准的 LaTeX,但\\(是。由于所有 Latex 编译器都使用底层 TeX 引擎,这从来都不是问题,但从挂件的角度来看,存在差异。

Use \\(...\\) and \\[...\\] .使用\\(...\\)\\[...\\]

  1. MathJax understands \\(...\\) but not $...$ . MathJax 理解\\(...\\)但不理解$...$ Some day you will want to use MathJax.有一天你会想要使用 MathJax。

  2. In 'Find and replace' it is easier to use \\( and \\) than $ and $ .在“查找和替换”中,使用\\(\\)比使用$$更容易。

    Eg imagine a situation where you wish to replace each \\(...\\) with \\[...\\] for proof reading purposes.例如,假设您希望将每个\\(...\\)替换为\\[...\\]以进行校对。

    I face this thing often, as I create some online courses for my university, and need to shift from LaTeX to HTML and vice versa.我经常遇到这个问题,因为我为我的大学创建了一些在线课程,并且需要从 LaTeX 转换到 HTML,反之亦然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM