
Я хотел бы спросить вас, возможно ли:
(1) удалить индекс слева и один в последней строке (все нули, выделены желтым)?
(2) удалить все строки внутри алгоритма (выделены зеленым)?
Вот код:
\documentclass[journal]{IEEEtran}
\usepackage[commentColor=black]{algpseudocodex}
\floatplacement{algorithm}{tbp}
\makeatletter
\newcommand{\algorithmname}{\ALG@name}
\renewcommand{\floatc@ruled}[2]{{\@fs@cfont #1} #2\par}
\makeatother
\tikzset{algpxIndentLine/.style={draw=black}}
\algrenewcommand{\alglinenumber}[1]{\bfseries\footnotesize #1}
\algrenewcommand{\textproc}{\bfseries}
\begin{algorithm}[h]
\caption{Sequence}
\begin{algorithmic}[1]
\Statex \textbf{Step I}
\State Do $U_{LL}$
\If{$n$ is odd number}
\State Do $U_n$
\Else
\State Do $L_n$
\EndIf
\Statex \textbf{Step II}
\For{$i=1,\ldots,n$}
\If{$i\bmod{2}==1$}
\State Do $L_i$
\Else
\State Do $U_i$
\EndIf
\EndFor
\Statex \textbf{Step III}
\For{$i=1,\ldots,n-1$}
\If{$i\bmod{2}==1$}
\State Do $U_i$
\Else
\State Do $L_i$
\EndIf
\EndFor
\State Do $L_{LL}$
\end{algorithmic}
\end{algorithm}
Заранее спасибо.
решение1
\documentclass[journal]{IEEEtran}
\usepackage{algorithm}
\floatplacement{algorithm}{tbp}
\makeatletter
\renewcommand{\floatc@ruled}[2]{{\@fs@cfont #1} #2\par}
\makeatother
\usepackage[commentColor=black,noEnd=false,indLines=false]{algpseudocodex}
\begin{document}
\begin{algorithm}
\caption{Sequence}
\begin{algorithmic}
\Statex \textbf{Step I}
\State Do $U_{LL}$
\If{$n$ is odd number}
\State Do $U_n$
\Else
\State Do $L_n$
\EndIf
\Statex \textbf{Step II}
\For{$i=1,\ldots,n$}
\If{$i\bmod{2}==1$}
\State Do $L_i$
\Else
\State Do $U_i$
\EndIf
\EndFor
\Statex \textbf{Step III}
\For{$i=1,\ldots,n-1$}
\If{$i\bmod{2}==1$}
\State Do $U_i$
\Else
\State Do $L_i$
\EndIf
\EndFor
\State Do $L_{LL}$
\end{algorithmic}
\end{algorithm}
\end{document}
решение2
Избавьтесь от бесполезных переопределений, которые по сути являются повторением значений по умолчанию.
Если вам не нужны направляющие отступы, укажите соответствующую опцию.
Однако у меня отображаются не нули, а номера строк, так что в вашем документе может быть что-то еще, что приводит к неправильной нумерации.
Если вам не нужны номера строк, не указывайте их [1]
после \begin{algorithmic}
, как показано во втором примере.
\documentclass[journal]{IEEEtran}
\usepackage{algorithm}
\usepackage[
commentColor=black,
indLines=false,
]{algpseudocodex}
\algrenewcommand{\alglinenumber}[1]{\bfseries\footnotesize #1}
\algrenewcommand{\textproc}{\bfseries}
\begin{document}
\begin{algorithm}
\caption{Sequence (with line numbers)}
\begin{algorithmic}[1]
\Statex \textbf{Step I}
\State Do $U_{LL}$
\If{$n$ is odd number}
\State Do $U_n$
\Else
\State Do $L_n$
\EndIf
\Statex \textbf{Step II}
\For{$i=1,\ldots,n$}
\If{$i\bmod{2}==1$}
\State Do $L_i$
\Else
\State Do $U_i$
\EndIf
\EndFor
\Statex \textbf{Step III}
\For{$i=1,\ldots,n-1$}
\If{$i\bmod 2==1$}
\State Do $U_i$
\Else
\State Do $L_i$
\EndIf
\EndFor
\State Do $L_{LL}$
\end{algorithmic}
\end{algorithm}
\newpage
\begin{algorithm}
\caption{Sequence (without line numbers)}
\begin{algorithmic}
\Statex \textbf{Step I}
\State Do $U_{LL}$
\If{$n$ is odd number}
\State Do $U_n$
\Else
\State Do $L_n$
\EndIf
\Statex \textbf{Step II}
\For{$i=1,\ldots,n$}
\If{$i\bmod 2==1$}
\State Do $L_i$
\Else
\State Do $U_i$
\EndIf
\EndFor
\Statex \textbf{Step III}
\For{$i=1,\ldots,n-1$}
\If{$i\bmod{2}==1$}
\State Do $U_i$
\Else
\State Do $L_i$
\EndIf
\EndFor
\State Do $L_{LL}$
\end{algorithmic}
\end{algorithm}
\end{document}