
다음과 같은 일이 가능한지 묻고 싶습니다.
(1) 왼쪽의 인덱스와 마지막 줄의 인덱스를 삭제합니다(모두 0, 노란색으로 강조 표시됨)?
(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
본질적으로 기본값을 다시 지정하는 쓸모없는 재정의를 제거하십시오.
들여쓰기 가이드를 원하지 않는 경우 해당 옵션을 지정하세요.
그러나 나는 0을 얻지 못하고 줄 번호만 얻습니다. 따라서 문서에 잘못된 번호 매기기를 만드는 다른 것이 있을 수 있습니다.
줄 번호를 원하지 않으면 두 번째 예와 같이 [1]
after 를 지정하지 마세요.\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}