Latex Algorithm 没有加粗

来源

写个 algorithm 流程,但是在 怎么设置以及换不同 algorithm 包 都导致 伪代码 开头的 “Algorithm” 不加粗。

解决方式

更换多个包以及copy别人模板,都是不加粗。猜想是和自己 preamble 中的部分包冲突。 复制一份 tex 文档,一个包一个包的调试,最后发现与 下面这个包 冲突。

\usepackage{floatrow}  

algorithm 模板

% Algorithm conflicts with \usepackage{floatrow}, leading to unbold Algorithm Keyword
\usepackage{algorithm}
\usepackage{algpseudocode}



\begin{algorithm}
        \caption{An algorithm with caption}\label{alg:cap}
        \textbf{Input:} Since SMA is a temperature activated material, the heat transfer model is developed in this section to study the temperature profile  \\
        \textbf{Output:} under internal resistive heating and compressed air cooling. Furthermore, incorporated it into the microscopic
        
        \begin{algorithmic}[1]
        % \Require $n \geq 0$
        % \Ensure $y = x^n$
        \State $y \gets 1$
        \State $X \gets x$
        \State $N \gets n$
        \While{$N \neq 0$}
        \If{$N$ is even}
            \State $X \gets X \times X$
            \State $N \gets \frac{N}{2}$  \Comment{This is a comment}
        \ElsIf{$N$ is odd}
            \State $y \gets y \times X$
            \State $N \gets N - 1$
        \EndIf
        \EndWhile
        \end{algorithmic}
\end{algorithm}

在这里插入图片描述

For loop
\begin{algorithm}
        \caption{Optimal design of SMA antagonistic actuator}
        \textbf{Input:} Required maximum bending $\alpha_{req}$, required stiffness $K_{req}$, required output force $F_{req}$. \\
        \textbf{Output:} Optimal length $L_{opt}$ and optical diameter $d_{opt}$.
        
        \begin{algorithmic}[1]
        % \Require $n \geq 0$
        % \Ensure $y = x^n$
        % \State $y \gets 1$
        % \State $X \gets x$
        % \State $N \gets n$

        \For{\texttt{$L \leftarrow L_{min}$ to $L_{max}$}}
                \For{\texttt{$d \leftarrow d_{min}$ to $d_{max}$}}
                        \State \texttt{$\alpha_{max} > \alpha_{req}$}
                        \State \texttt{$\alpha_{max} > \alpha_{req}$}
                \EndFor
        \EndFor
        \end{algorithmic}
        \label{alg:cap}
\end{algorithm}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
要使 LaTeX algorithm 中的 "Algorithm" 加粗,可以使用 algorithm2e 宏包。首先,确保已经正确加载了 algorithm2e 宏包。然后,在 \begin{algorithm} 之前添加以下命令: \SetAlgoCaptionSeparator{.} \renewcommand{\algorithmcfname}{\textbf{Algorithm}} 这些命令会设置算法标题的分隔符和算法关键词的样式。接下来,在你的算法代码之前添加以下命令: \textbf{Algorithm} \caption{Your caption}\label{alg:label} 这个命令会将 "Algorithm" 加粗,并在标题前显示。在你的算法代码中,你可以继续使用 \State 和其他算法关键字来编写伪代码。 在你的算法代码结束之后,添加以下命令: \end{algorithm} 这个命令会结束算法环境。 总结一下,要使 LaTeX algorithm 中的 "Algorithm" 加粗,你需要: 1. 加载 algorithm2e 宏包 2. 在 \begin{algorithm} 之前添加 \SetAlgoCaptionSeparator{.} 和 \renewcommand{\algorithmcfname}{\textbf{Algorithm}} 3. 在算法标题之前添加 \textbf{Algorithm} \caption{Your caption}\label{alg:label} 4. 在算法代码之后添加 \end{algorithm} 这样就可以使算法标题中的 "Algorithm" 加粗了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Latex algorithm2e 算法伪代码 官方介绍文档.pdf](https://download.csdn.net/download/yyl424525/12045988)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Latex Algorithm 没有加粗](https://blog.csdn.net/jh1513/article/details/129124385)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值