我想用 latex 写一个算法,但是编译后,它看起来像这样: 从外观上看,“Input”、“Initialize”、“while”、“end while”和“Output”等关键字没有以粗体显示,我想知道是否存在问题以及如何纠正它。
\begin{algorithm}
\caption{Title of the Algorithm}
\label{algo:ref}
\begin{algorithmic}[1]
\REQUIRE some words. % this command shows "Input"
\ENSURE ~\\ % this command shows "Initialized"
some text goes here ... \\
\WHILE {\emph{not converged}}
\STATE ... \\ % line number at left side
\ENDWHILE
\RETURN this is the lat part. % this command shows "Output"
\end{algorithmic}
\end{algorithm}
另外,我还用了网上的一个模板,模板介绍如下,谢谢大家的帮助!
\documentclass[UTF8,a4paper,10pt]{ctexart}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry} %页边距
\CTEXsetup[format={\Large\bfseries}]{section} %设置章标题居左
\setmainfont{STSong} % 宋体
\usepackage{authblk}
\usepackage{amsmath, amsfonts, amssymb} % math equations, symbols
\usepackage[english]{babel}
\usepackage{color} % color content
\usepackage{graphicx} % import figures
\usepackage{url} % hyperlinks
\usepackage{bm} % bold type for equations
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{epstopdf}
\usepackage{epsfig}
\usepackage{algorithm}
\usepackage{algorithmic}
\renewcommand{\algorithmicrequire}{ \textbf{Input:}} % use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{ \textbf{Initialize:}} % use Initialize in the format of Algorithm
\renewcommand{\algorithmicreturn}{ \textbf{Output:}} % use Output in the format of Algorithm
\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}
\usepackage{fancyhdr} %设置页眉、页脚
\lhead{}
\chead{}
\lfoot{}
\cfoot{}
\rfoot{}
\usepackage{hyperref} %bookmarks
\hypersetup{colorlinks, bookmarks, unicode} %unicode
\makeatletter
\@addtoreset{equation}{section}
\makeatother
\title{\textbf{均匀设计方法综述}}
\author{ 陈海硕}
\affil{ 统计学院 }
\date{\today}