格式化下划线的最大垂直间距并查找文档中的最大垂直间距

格式化下划线的最大垂直间距并查找文档中的最大垂直间距

例子

\documentclass{article}

\usepackage{mathtools}
\usepackage{algpseudocode}

 \newcommand{\smashundermin}[1]{\underset{\makebox[2pt]{}\smash{\mathclap{#1}}}{\:\operatorname{min}}\:}
 
\begin{document}
I don't like how underset/subscript messes with $v_{dir}$: \newline $\g_{dir}(s) = \smashundermin{u \in \textproc{PRED}_{dir}(s)}(v_{dir}(u) + c(u,s))$. Also, is there a way to calculate the largest vertical line space caused by underset and set the document to have uniform line spacing?
\end{document}

答案1

解决垂直间距问题的一种方法是修改\smashundermin宏以删除\smash指令并添加\vphantom指令。更好的方法是仅在显示数学模式下使用具有大量下划线材料的宏。

在此处输入图片描述

\documentclass{article}

\usepackage{mathtools,xcolor}

\newcommand{\smashundermin}[1]{\underset{\makebox[2pt]{}\smash{\mathclap{#1}}}{\:\operatorname{min}}\:}
\newcommand{\undermin}[1]{\underset{\mathclap{#1}\vphantom{)^{)^a}}}{\min}}
\begin{document}
\textcolor{red}{Before}

I don't like how underset/subscript messes with $v_{dir}$: 

$g_{dir}(s) = \smashundermin{u \in \textup{PRED}_{dir}(s)}(v_{dir}(u) + c(u,s))$. Also, is there a way to calculate the largest vertical line space caused by underset and set the document to have uniform line spacing?

\medskip
\textcolor{red}{After}

I don't like how underset/subscript messes with $v_\textup{dir}$: 

$g_{\textup{dir}}(s) = \undermin{u \in \textup{PRED}_{\textup{dir}}(s)}(v_{\textup{dir}}(u) + c(u,s))$. Also, is there a way to calculate the largest vertical line space caused by underset and set the document to have uniform line spacing?

\medskip
\textcolor{red}{Even better}

Underset/subscript no longer messes with $v_\textup{dir}$: 
\[
g_{\textup{dir}}(s) = \undermin{u \in \textup{PRED}_{\textup{dir}}(s)}(v_{\textup{dir}}(u) + c(u,s)) 
\]
Also, is there a way to calculate the largest vertical line space caused by underset and set the document to have uniform line spacing?

\end{document}

相关内容