LaTeX公式中的标点符号

Oli*_*ier 8 latex punctuation

在编写数学时,似乎通常的做法是在显示的公式中添加标点符号.

是否有任何技巧可以避免在标准公式中加入标点符号?

我想避免

Consider the function
\[ \sin(x).\]
Run Code Online (Sandbox Code Playgroud)

我宁愿有类似的东西:

Consider the function
\[ \sin(x)\].
Run Code Online (Sandbox Code Playgroud)

但当然,完整的停止会显示在公式下方.

是否有一种聪明的方法来分离LaTeX中的公式和标点符号?

Ale*_*tov 10

\catcode`\@=11 
\let\seveendformula\]
\def\]{\@ifnextchar.\PointAndEndFormula\seveendformula}
\def \PointAndEndFormula #1{.\seveendformula}
\catcode`\@=12 
Run Code Online (Sandbox Code Playgroud)

更复杂的解决方案适用于.,?!;::

\catcode`\@=11 
\def\addtopunct#1{\expandafter\let\csname punct@\meaning#1\endcsname\let}
\addtopunct{.}    \addtopunct{,}    \addtopunct{?}
\addtopunct{!}    \addtopunct{;}    \addtopunct{:}

\let\seveendformula\]
\def\PunctAndEndFormula #1{#1\seveendformula}
\def\]{\futurelet\punctlet\checkpunct@i}
\def\checkpunct@i{\expandafter\ifx\csname punct@\meaning\punctlet\endcsname\let  
       \expandafter\PunctAndEndFormula 
       \else \expandafter\seveendformula\fi}
\catcode`\@=12 
Run Code Online (Sandbox Code Playgroud)


lhf*_*lhf 8

标点符号应该是哪种字体的问题.在尝试使用其他数学字体(例如Euler)之前,您不会看到问题.然后在文本模式和数学模式中逗号和句点明显不同.我已经在显示的公式中编写了文本模式标点符号,\mbox{,}或者像\mbox,之前一样懒惰$$.


Wil*_*son 5

您可以加载breqn 包(与 amsmath 兼容)并在其 dmath 环境中内置此行为:

Consider the function
\begin{dmath}\sin(x)\end{dmath}.
Run Code Online (Sandbox Code Playgroud)

将输出与 相同\[\sin(x).\],即,就好像点在表达式中一样。

作为奖励,您还将在数学方程式中自动换行。