分裂根符号

分裂根符号

如何\sqrt修改命令以自动将根符号拆分为两行或多行?

例子:

\documentclass{standalone}

\begin{document}
    \begin{minipage}[t]{0.8\textwidth}
        The \textbf{Euclidean distance} between two points $P=(x, y, z)$and $Q=(a, b, c)$
        in space is defined as $d(P, Q)= \sqrt{(x - a)^{2} + (y - b)^{2} + (z - c)^{2}}$.
        The distance between a point $P$ and a geometric object $S$ like a line or plane is
        the minimal distance $d(P, Q)$ which is possible with $Q$ on $S$.
    \end{minipage}
\end{document}

有

我想要这样的东西(使用人工示例\overline):

\documentclass{standalone}

\begin{document}
    \begin{minipage}[t]{0.8\textwidth}
        The \textbf{Euclidean distance} between two points $P=(x, y, z)$and $Q=(a, b, c)$
        in space is defined as $d(P, Q)= \sqrt{(x - a)^{2} +}$ $\overline{(y - b)^{2} + (z - c)^{2}}$.
        The distance between a point $P$ and a geometric object $S$ like a line or plane is
        the minimal distance $d(P, Q)$ which is possible with $Q$ on $S$.
    \end{minipage}
\end{document}

想

答案1

此版本允许 TeX 自动分解数学运算。在此版本中,您只能执行一次此操作,而完整版本每次都需要计数器并为点生成新的唯一名称。

在此处输入图片描述

\documentclass{article}

\makeatletter
\def\savepos#1{\leavevmode\pdfsavepos\write\@auxout{%
\gdef\string\save@#1{{\the\pdflastxpos sp }{\the\pdflastypos sp }}}}

\def\xx#1{\expandafter\expandafter\expandafter\@firstoftwo\csname save@#1\endcsname}
\def\yy#1{\expandafter\expandafter\expandafter\@secondoftwo\csname save@#1\endcsname}


\def\xsqrt#1{%
\sqrt{\vphantom{#1}}%
\ifx\save@L\@undefined
\else
\ifdim\yy{L}=\yy{R}%
\else
\rlap{$\overline{\vphantom{#1}\hskip\dimexpr\xx{b}-\xx{L}\relax}$}%
\fi
\fi
\savepos{L}#1\savepos{R}%
\ifx\save@L\@undefined
\else
\ifdim\yy{L}=\yy{R}%
\llap{$\overline{\hskip\dimexpr\xx{R}-\xx{L}\relax}$}%
\else
\llap{$\overline{\vphantom{#1}\hskip\dimexpr\xx{R}-\xx{a}\relax}$}%
\fi
\fi
}

\makeatother

\begin{document}



    \savepos{a}\begin{minipage}[t]{0.8\textwidth}
        The \textbf{Euclidean distance} between two points $P=(x, y, z)$ and $Q=(a, b, c)$
        in space is defined as $d(P, Q)= \xsqrt{(x - a)^{2} +(y - b)^{2} + (z - c)^{2}}$.
        The distance between a point $P$ and a geometric object $S$ like a line or plane is
        the minimal distance $d(P, Q)$ which is possible with $Q$ on $S$. 
    \end{minipage}\savepos{b}
\end{document}

答案2

对于您提到的情况,我认为如果您根本不使用“surd”符号,对您来说会更简单,对您的读者来说也会更清楚。相反,请使用[...]^{1/2},就像您在 MWE 的以下修改形式中所做的那样。或者,正如其他人已经建议的那样,您可以将长期项移到“显示”方程中,即移到一条单独的线上。

这不仅[...]^{1/2}对您来说更简单(因为您不必担心换行符会落在哪里),而且对读者来说也更容易(即更少分散注意力,因此也更清晰),因为相关段落中的行间距不必调整以适应“surd”。

在此处输入图片描述

\documentclass{standalone}
\begin{document}
\begin{minipage}{0.8\textwidth}
The \textbf{Euclidean distance} between two points $P=(x, y, z)$ and 
$Q=(a, b, c)$ in space is defined as $d(P, Q)= [(x - a)^{2} +(y - b)^{2} 
+ (z - c)^{2}]^{1/2}$. The distance between a point $P$ and a geometric 
object $S$, such as a line or plane, is the minimal distance $d(P, Q)$ 
which is possible with $Q\in S$.
\end{minipage}
\end{document}

答案3

在此处输入图片描述

\documentclass[preview,border=12pt]{standalone} % change it to your class!

\usepackage{mathtools}


\begin{document}
\begin{multline*}
A   = \sqrt{a+b+c} \\
    \overline{\rule{0pt}{2.5ex}+d+e+f}\\
    \overline{\rule{0pt}{2.5ex}+g+h+i}
\end{multline*}
\end{document}

再举一个例子:

在此处输入图片描述

\documentclass[preview,border=12pt]{standalone}% change it to your own document class!
\usepackage[a6paper,margin=1cm]{geometry}
\usepackage{mathtools}


\begin{document}
\begin{multline*}
d(x,y)  
    = \sqrt{(x-x_0)^2} \\
        \overline{\rule{0pt}{2.5ex}{}+(y-y_0)^2}\\
        \overline{\rule{0pt}{2.5ex}{}+(z-z_0)^2}
\end{multline*}
\end{document}

答案4

这里有一个简单的解决方案。当你需要时,只需使用 new 命令并根据需要拆分部首即可。

\newcommand{\sqrtx}[2]{\sqrt{#1}\\\overline{#2}}

here some text \dotfill$\sqrtx{x^2+y^2}{z^2+y^2}$

在此处输入图片描述

相关内容