latex基础排版语法

3 阅读1分钟

注释

使用百分号:%,快捷键ctrl+/

换行 

  1. 换行回车:两段之间空一行
  2. 换行: \\
  3. 换页: \newpage

章节

一级标题 \section{标题内容}
二级标题 \subsection{标题内容}
三级标题 \subsubseection{标题内容}
四级标题 \paragraph{标题内容},不建议使用

不要序号的标题,在括号前加星号,如:\section*{附录}

制作目录

\paleocontacts

无序号的部分不会自动出现在目录中,添加到目录中需要在无序号标题后加:\addcontentsline{toc}{section}{(内容)},如

\section*{参考文献}
\addcontentsline{toc}{section}{参考文献}

列表

\begin{enumerate} 有序列表
    \item ...
    \item ...
\end{enumerate}

无序列表: 使用itemize替换enumerate

插入代码

  1. \verb |for| 会使用等宽字体
\begin{verbatim}
    print("hello,latex")
\end{verbatim}

插图和插表

  1. 首先需要导入宏包,在开头部分:\usepackage{graphicx}
  2. 在需要插入图片的地方写如下代码:
\begin{figure}[ht]
    \centering  %居中
    \includegraphics[width=0.35\textwidth]{文档路径}
    \caption{}  %题注,如:模型结构图
    \label{img:lena} 给图片定义命名,在正文中可以使用:“如图\ref{img:lena}所示”,img不是强制要求
\end{figure}

制作表格

latex不方便,可以使用Create LaTeX tables online–TablesGenerator.com网站来可视化制作

公式

  1. 行内公式,$公式$,鼠标放上会实时显示
  2. 行间公式
\begin{equation}
    \begin{aligned}
        y & = x^2+2x+z \\
        &=(x+1)^2 \\ &为对齐符号
    \end{aligned}
    \label{equ:1} 在其它地方使用ref{equ:1}来引用
\end{equation}

排版(图片、表格)

参数含义说明
hhere当前位置(不常用,限制严格)
ttop页面顶部
bbottom页面底部
ppage单独一页
!override强制忽略某些限制(如浮动限制)