我设法删除了标题标签和编号,但新标题并未完全居中,如下所示。那么,如何真正居中新标题样式呢?
\documentclass{article}
\usepackage{xcolor,hyperref}
\usepackage[
ruled,
vlined,
commentsnumbered,
shortend,
nofillcomment,
]{algorithm2e}
\SetVlineSkip{10pt}
\newcommand\mycommfont[1]{\footnotesize\ttfamily\textcolor{green!60!black}{#1}}
\SetCommentSty{mycommfont}
\SetKwComment{tcc}{\% }{ \%}
\newcommand{\mycapsty}[1]{\centering\normalfont#1}
\SetAlCapNameSty{mycapsty}
\makeatletter
\renewcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt}}
\makeatother
\SetAlgoCaptionSeparator{}
\setlength{\algomargin}{5mm}
\begin{document}
\begin{algorithm}
\DontPrintSemicolon
\BlankLine
Algorithm Body\;\BlankLine
\tcc{Loop}
\caption{long long long long long long long long long long caption to center}
\end{algorithm}
\end{document}