0

I want to write an algorithm in latex. But after compiling, it looks like that: enter image description here As it looks, keywords like "Input", "Initialize","while", "end while" and "Output" don't appear in bold, I wonder if there is something wrong and how I can correct it.

    \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}

Besides, I used a template from Internet, and its introduction is as follows. Thanks for your help!

\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}
  • Have a look at the listings package. – susis strolch Jul 15 at 4:04
  • Hi and welcome. Please give a fully compilable code. – AndréC Jul 15 at 5:28
1

On the macOS 10.15, the warning says that the font TU/STSong(0)/b/n (font STSong bold) was unavailable (it doesn't exist) and that instead LaTeX used font TU/STSong(0)/m/n (font STSong).

Basically, you can't have bold (also italic) text with this set of fonts because this particular font doesn't exist.

Just delete the line \setmainfont{STSong} should resolve the issue or use another font that has both bold and italic shapes, e.g., Times New Roman.

enter image description here

| improve this answer | |
  • It works! Thank you! When I delete this line. The keywords appear in bold. – Hahashuo Jul 15 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.