宏定义
\def
\long\def
, \long
一般的宏是不允许使用分段符号\par来充当参数的。要允许宏接收分段符号充当参数,那就在\def前面增加一个\long.
\def和\newcommand的区别
- \newcommand is part of LaTeX; \def is part of TeX.
- \newcommand fails if the command is already defined; \def doesn’t.
- \newcommand provides a convenient syntax for specifying the number of arguments, and specifying a (single) optional argument; \def enables pattern-matching on the form of its arguments, which makes it more general but also less readable.
- \newcommand can’t define a command whose name starts with “end”; \def can.
- \newcommand defines “long” commands; \def (unless \long\def is used) defines short ones. (The arguments of a “long” command can include paragraph breaks.)
See: What is the difference between \def and \newcommand?
Warning–entry type for “…” isn’t style-file defined
说明你bib里有一条entry的类型在你的reference格式里不支持. 比如@dataset, @webpage等. 可以换成@misc
警告有文献没有正确引用, 但是bib里有
应该是你的bst文件里要求year, 但是entry里缺year这个item, 手动添加就好.
使用Times New Roman
latex自己是不带Times New Roman这个字体的. 所以要借助其他方法实现
- 使用
\usepackage{mathptmx}
包, 可以呈现类似Times New Roman的效果, 或者 - 使用
XeLaTeX
编译器, 然后使用如下命令(详情看这里):
\usepackage{fontspec}
\setmainfont{Times New Roman}
段间距与行间距
\setlength{\lineskip}{1em}
设置行间距
\setlength{\parskip}{2em}
设置段落间距
设置缩进
\setlength{\parindent}{0pt}
之后的所有段落都将取消缩进
\noindent
只取消该段的首行缩进
设置页边框
\usepackage{geometry}
\geometry{left=3.18cm,right=3.18cm,top=2.54cm,bottom=2.54cm} % a4, normal margin
latex插入随机英语文本
\usepackage{kantlipsum}
\kant[1-5] % 1-5段
latex按原样输出
比如要直接输出一些命令, 类似markdown\noindent
这种的话, 可以使用verbatim包. 不然latex会自动把它当成命令而没法输出.
\usepackage{verbatim}
\begin{verbatim}
\noindent
\end{verbatim}
如果不使用块命令的话, 可以用短命令 \verb|\noindent|
另外\texttt{}
也可以实现类似功能, 但是\texttt{}
会自动去掉括号内的空格, 也允许换行.
latex输入右斜线
需要使用命令\textbackslash
来输入\
Latex去掉ACM模板的copyright部分
\setcopyright{none}
\makeatletter
\renewcommand\@formatdoi[1]{\ignorespaces}
\makeatother
\settopmatter{printacmref=false} % remove citation
\renewcommand{\footnotetextcopyrightpermission}[1]{} % remove copyright
\pagestyle{plain}
去掉ACM模板的页眉
去acmart.cls中把\pagestyle{standardpagestyle}
改成\pagestyle{empty}
如果想要页码, 就改成\pagestyle{plain}
靠右对齐
居中的话直接用\centering
就可以了.
靠右可以使用
\begin{flushright}
...
\end{flushright}
此方法对于图片也适用
如果只需要一行对齐, 可以使用 \rightline{text}
输入尖括号
latex里直接使用<>
属于非法字符, 转义过后也不行. 如果想使用的话可以利用数学公式:
\langle \rangle
来表示.
ACM 模板显示页数
在\maketitle前加上:
\settopmatter{printfolios=true}
Command `\Bbbk’ already defined
amssymb包前面加上一个命令让Bbbk失效.
\let\Bbbk\relax
\usepackage{amssymb}