如果上標和下標彼此靠近,如何在演算法中的行之間添加額外的空格?

如果上標和下標彼此靠近,如何在演算法中的行之間添加額外的空格?

當上線有subscripts且下線有時,superscripts它們最終可能在演算法中非常接近。

如果線最終彼此如此接近,是否可以在演算法中的線之間放置額外的空間?

我有以下程式碼:

\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage[table]{xcolor}
\usepackage{eulervm}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{algorithmicx}
\usepackage{algorithm}
\begin{document}
\begin{algorithm}
    \caption{The sadWorld Function}
    \hspace*{\algorithmicindent} \textbf{Input:} {}
    \begin{algorithmic}[1]
        \State{}{$j{.}Z_{H_{d_i}}^{\mathrm{pr}} \gets 0 $}
        \State{}$p_n{.}\Pi^{\mathrm{p}}[H_{d_i}] \gets 0$
    \end{algorithmic}
\end{algorithm}
\end{document}

它的輸出:

在此輸入影像描述

在這裡,當你仔細觀察時$d_i$p彼此非常接近,因此i可以被視為 的上標p。是否可以在它們之間添加額外的空間(第 1 行和第 2 行)?如果可能的話,請自動處理此操作。

答案1

您可以新增一些 vspace:

\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage[table]{xcolor}
\usepackage{eulervm}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{algorithmicx}
\usepackage{algorithm}
\begin{document}
\begin{algorithm}
    \caption{The sadWorld Function}
    \hspace*{\algorithmicindent} \textbf{Input:} {}
    \begin{algorithmic}[1]
        \State{}{$j{.}Z_{H_{d_i}}^{\mathrm{pr}} \gets 0 $}
        \vspace*{3mm}
        \State{}$p_n{.}\Pi^{\mathrm{p}}[H_{d_i}] \gets 0$
    \end{algorithmic}
\end{algorithm}
\end{document}

在此輸入影像描述

相關內容