![algorithm2e 中的 \SetAlgoLined 问题](https://linux22.com/image/465921/algorithm2e%20%E4%B8%AD%E7%9A%84%20%5CSetAlgoLined%20%E9%97%AE%E9%A2%98.png)
我对 Latex 还很陌生。我在 algorithm2e 中的 \SetAlgoLined 方面遇到了问题。从图片中可以看出,在 while 循环内部,线条似乎正常。我不知道为什么在 while 循环外部,线条看起来很奇怪。
\documentclass{article}
\usepackage[ruled,vlined,algo2e]{algorithm2e}
\begin{document}
\begin{algorithm2e}
\SetAlgoLined
\SetKwInOut{Input}{Subscribe}\SetKwInOut{Output}{Publish}
\SetKw{Set}{set}
\SetKw{Read}{read}
\SetAlFnt{\large}
\SetAlCapFnt{\large}
\SetAlCapNameFnt{\large}
\caption{Single Robot Auto Navigation}
\Input{initialize\_state, custom\_waypose ($q_i,\alpha_i$), robot\_status, camera\_interrupt, object\_depth}
\Output{robot\_pose ($p_i,\alpha_i$), sphere\_marker\_position ($q$) }
\If{finished initialize\_state}{
\Read {custom\_waypose}\;
\For{waypoint ($q_i$) in custom\_waypose:}{
\For{wayorientation ($\theta_i$) in custom\_waypose:}{
\Set{WAIT to robot\_status}\;
$p_i = q_i$\;
$\theta_i = \alpha_i$\;
return waypose\;
\While{waiting robot\_status}{
\If {robot reached goal}{
break\;}
\If {camera_interrupt}{
$q_i_x = p_i_x+ object\_depth * sin(\theta_i)$\;
$q_i_y = p_i_y+ object\_depth * cos(\theta_i)$ \;
return sphere marker (q)\;
end program\;
}
}
}
}
}
\end{algorithm2e}
\end{document}
答案1
您的代码出现多个错误。解决它们,就解决了您的问题。
- 缺少插入 $。
camera_interrupt
->camera\_interrupt
- 4次双下标
q_i_x
->q_{i_x}
(如果这是你的意思),等等。- 也可以看看子序列的双下标
\documentclass{article}
\usepackage[ruled,vlined,algo2e]{algorithm2e}
\begin{document}
\begin{algorithm2e}
\SetAlgoLined
\SetKwInOut{Input}{Subscribe}\SetKwInOut{Output}{Publish}
\SetKw{Set}{set}
\SetKw{Read}{read}
\SetAlFnt{\large}
\SetAlCapFnt{\large}
\SetAlCapNameFnt{\large}
\caption{Single Robot Auto Navigation}
\Input{initialize\_state, custom\_waypose ($q_i,\alpha_i$), robot\_status, camera\_interrupt, object\_depth}
\Output{robot\_pose ($p_i,\alpha_i$), sphere\_marker\_position ($q$) }
\If{finished initialize\_state}{
\Read {custom\_waypose}\;
\For{waypoint ($q_i$) in custom\_waypose:}{
\For{wayorientation ($\theta_i$) in custom\_waypose:}{
\Set{WAIT to robot\_status}\;
$p_i = q_i$\;
$\theta_i = \alpha_i$\;
return waypose\;
\While{waiting robot\_status}{
\If {robot reached goal}{
break\;}
\If {camera\_interrupt}{
$q_{i_x} = p_{i_x}+ object\_depth * sin(\theta_i)$\;
$q_{i_y} = p_{i_y}+ object\_depth * cos(\theta_i)$ \;
return sphere marker (q)\;
end program\;
}
}
}
}
}
\end{algorithm2e}
\end{document}