在 LaTeX 中定义变量

介绍

在撰写科研论文时,我们经常给自己的模型起一个方便使用的名字,例如 ResNet 等。通常这个模型名字(或者其他类似的东西)会在论文中出现多次。我们在写论文的时候,可能有时候

需要换个模型名输错了模型名

那么,使用变量来定义模型的名字就非常方便了。本篇博客介绍如何在 LaTeX\LaTeXLATE​X 中定义变量。

用法

首先直接定义一个新的命令:

\newcommand{\M}{ResNet}

然后使用 \M(或者其他符号) 来表示你所定义的模型名,例如ResNet:

This is the \M~framework.

注意

在命令之后直接跟空格,会忽略掉这个空格,此时应该用~符号代替空格。例如,\M framework的输出是ResNetframework,而\M~framework的输出是ResNet framework。

示例

代码

\documentclass{article}

\usepackage[utf8]{inputenc}

\newcommand{\M}{ResNet}

\title{\textbf{An Introduction to \M}}

\author{Xovee Xu}

\date{December 2020}

\begin{document}

\maketitle

\section{Introduction}

This article explains how to write the word \M~\cite{he2016deep}. Now you know how to type \M, congrats!

And a tip: if there is a space after the name of \M~then you should use ``\verb|~|'' character to substitute the space ``\verb| |''. For example, \verb|a ResNet~network| is the right code and \verb|a ResNet network| is the wrong code and will result in \verb|a ResNetnetwork|.

\bibliography{name}

\bibliographystyle{plain}

\end{document}

Copyright © 2088 网络游戏活动中心 - 最新游戏活动汇总 All Rights Reserved.
友情链接