\documentclass[twocolumn]{ltxdoc}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath} %
\usepackage{lineno}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{lipsum}
\usepackage[margin=1in]{geometry}
\documentclass{article}
\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm
\usepackage{fancyvrb}
\usepackage{fvextra}
\begin{document}
\begin{algorithm}[H]
\caption{}
\label{alg:algorithm1}
\begin{algorithmic}[1]
\State Required system configuration ($RSC$) = Find\_required\_configuration($BoPs$, $BoRs$)
\end{algorithmic}
\end{algorithm}
\end{document}
答案1
空格变得如此之大是因为 latex 无法将长变量名与下一行连字符连接起来。您可以帮助 latex 找到可能的连字符点,但结果可能会令人困惑。
为了避免作品之间的空间过大,您可以将文本设置为\raggedright
:
\documentclass[twocolumn]{ltxdoc}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath} %
\usepackage{lineno}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{lipsum}
\usepackage[margin=1in]{geometry}
%\documentclass{article}
\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm
\usepackage{fancyvrb}
\usepackage{fvextra}
\begin{document}
\begin{algorithm}[H]
\caption{}
\label{alg:algorithm1}
\begin{algorithmic}[1]
\raggedright
\State Required system configuration ($RSC$) = Find\_required\_configuration($BoPs$, $BoRs$)
\end{algorithmic}
\end{algorithm}
\end{document}