我正在使用algorithm2e
套件來編寫演算法,並且嘗試在螢幕截圖的程式碼中添加第 3 行和第 4 行作為註釋,\tcc{}
但不帶 seccuss。如何在algorithm2e
包中添加評論?
代碼:
\documentclass{article}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\renewcommand{\baselinestretch}{1.5}
\usepackage{amsmath}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{2 graphs $T$ and $\acute{T}$ with nodes V and $\acute{V}$.}
\KwResult{Find whether $T$ and $\acute{T}$ are isomorph.}
function($T$, $\acute{T}$) \\
\Indp covert $T$ to $P_v$ and $\acute{T}$ to $\acute{P_v}$ ;\\
$d=deg(P_T) \leq h(T)$ and $S=\{1,2,3,\dots,2h(T)\}$; \\
$\acute{d} =deg(\acute{P_T}) \leq h(\acute{T})$ and $\acute{S}=\{1,2,3,\dots,2h(\acute{T})\}$; \\
\eIf{$Pr[P_v = \acute{P_v}] = \frac{d}{S}=\frac{h(T)}{2h(T)} ==\frac{1}{2}$}{
return true;
}{
return false;}
\end{algorithm}
\end{document}
答案1
我只是嘗試過
\tcc{$d=deg(P_T) \leq h(T)$ and $S=\{1,2,3,\dots,2h(T)\}$}
\tcc{$\acute{d} =deg(\acute{P_T}) \leq h(\acute{T})$ and $\acute{S}=\{1,2,3,\dots,2h(\acute{T})\}$}
它工作沒有問題。只需小心地; \\
從行尾刪除即可。