LaTeX入门——制作一份朴实无华的pdf文档

2023-11-22 05:40

本文主要是介绍LaTeX入门——制作一份朴实无华的pdf文档,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

目录

  • 作者、标题、日期
  • 章节和段落
  • 插入目录
  • 枚举
  • 插入图片
  • 表格
  • 排版
  • 插入代码块
  • 数学公式
  • 树形图
  • 页边距

作者、标题、日期

文章部分开头\begin{document},结尾\end{document}

\documentclass[UTF8]{ctexart}
\title{你好,world!}
\author{Liam}
\date{\today}
\begin{document}
\maketitle
你好,world!
\end{document}

排版示例:
在这里插入图片描述

章节和段落

\maketitle 后面加文字:出现在文章最上方。
\section{你好中国} 第一个大部分,后面加文字,解释说明用。(1)
\subsection{Hello Beijing} (1.1)
\subsubsection{Hello Dongcheng District} (1.1.1)
\paragraph{Tian'anmen Square}, \subparagraph{Chairman Mao} 针对每个section分段。

\documentclass[UTF8]{ctexart}
\title{你好,world!}
\author{Liam}
\date{\today}
\begin{document}
\maketitle
\section{你好中国}
中国在 East Asia.
\subsection{Hello Beijing}
北京是 capital of China.
\subsubsection{Hello Dongcheng District}
\paragraph{Tian'anmen Square}
is in the center of Beijing
\subparagraph{Chairman Mao}
is in the center of 天安门广场。
\subsection{Hello 山东}
\paragraph{山东大学} is one of the best university in 山东。
\end{document}

排版示例:
在这里插入图片描述

插入目录

\maketitle 后加入\tableofcontents 自动生成目录。
排版示例:
在这里插入图片描述

枚举


```cpp
\begin{itemize}%圆点 罗列
\item 我的第一个项目
\item 我的第二个项目
\item 我的第三个项目
\end{itemize}\begin{enumerate}%带有数字标号的罗列
\item 我的第一个项目
\item 我的第二个项目
\item 我的第三个项目
\end{enumerate}\begin{description}%不带任何符号的罗列
\item 我的第一个项目
\item 我的第二个项目
\item 我的第三个项目
\end{description}

插入图片

在导言部分加入:
注意:引言区就是指的从\documentclass 开始到\begin[document]的这个部分的区域。

\usepackage{graphicx}
  1. 在文档中插入a.jpg文件。
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{a.jpg}
\end{document}

注意:如何插入图片呢?首先将编写的tex文件放入文件夹中,再将用到的图片同样导入文件夹中,这样就可以使用该图片了。

  1. 浮动体(更常用)
    \centering表示的是里面紧跟的内容都居中
    \includegraphics[]{}表示的插入图片
    \caption设置图片的一个编号以及为图片添加标题
\begin{figure}[ht]
\centering
\includegraphics[scale=0.6]{fullscreen.png}
\caption{this is a figure demo}
\label{fig:label}
\end{figure}
-------------------------------------注	h 此处(here)t 页顶(top)b 页底(bottom)p 独立一页(page)
--------------------------------------
  1. 多图并排
    设置库:
\ifCLASSOPTIONcompsoc
\usepackage[caption=false,font=normalsize,labelfon
t=sf,textfont=sf]{subfig}
\else
\usepackage[caption=false,font=footnotesize]{subfig}
\fi

设置图片:

\begin{figure*}[!t]
\centering
\subfloat[]{\includegraphics[width=2.5in]{luna.jpg}%
\label{fig_first_case}}
\hfil
\subfloat[]{\includegraphics[width=2.5in]{luna.jpg}%
\label{fig_second_case}}
\hfil
\subfloat[]{\includegraphics[width=2.5in]{luna.jpg}%
\label{fig_third_case}}
\hfil
\subfloat[]{\includegraphics[width=2.5in]{luna.jpg}%
\label{fig_forth_case}}
\caption{Simulation results for the network.}
\label{fig_sim}
\end{figure*}

表格

使用\begin{tabular}{|l|c|r|}\end{tabular} 建立表格。
\hline 分割线。
& 列结束。
\\ 行结束。

\begin{tabular}{|l|c|r|}\hline
操作系统& 发行版& 编辑器\\\hline
Windows & MikTeX & TexMakerX \\\hline
Unix/Linux & teTeX & Kile \\\hline
Mac OS & MacTeX & TeXShop \\\hline
通用& TeX Live & TeXworks \\\hline
\end{tabular}

在这里插入图片描述

排版

段尾加 \\,表示换行。
段尾不加 \\ ,直接空一行再输入,表示换行并且段首空格。

插入代码块

无高亮
插入如下格式:

\usepackage{listings}
\usepackage{xcolor}%代码设置
\lstset{numbers=left, %设置行号位置numberstyle=\tiny, %设置行号大小keywordstyle=\color{blue}, %设置关键字颜色commentstyle=\color[cmyk]{1,0,1,0}, %设置注释颜色escapeinside=``, %逃逸字符(1左面的键),用于显示中文breaklines, %自动折行extendedchars=false, %解决代码跨页时,章节标题,页眉等汉字不显示的问题xleftmargin=1em,xrightmargin=1em, aboveskip=1em, %设置边距tabsize=4, %设置tab空格数showspaces=false %不显示空格}\begin{lstlisting}[language=R]
> matrix(1:12,nrow=3,ncol=4)[,1] [,2] [,3] [,4]
[1,]   1   4   7   10
[2,]   2   5   8   11
[3,]   3   6   9   12
\end{lstlisting}

示例:
在这里插入图片描述

数学公式

行内$xx$ ,单独公式$$xxx$$
1.方程组:

F(n)=
\begin{cases}
1 & \text{n=0 or n=1}\\
F(n-1)+F(n-2) & \text{n>1}
\end{cases}

F ( n ) = { 1 n=0 or n=1 F ( n − 1 ) + F ( n − 2 ) n>1 F(n)= \begin{cases} 1 & \text{n=0 or n=1}\\ F(n-1)+F(n-2) & \text{n>1} \end{cases} F(n)={1F(n1)+F(n2)n=0 or n=1n>1
2.矩阵

\left\{
\begin{matrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{matrix}
\right\} \tag{2}

{ 1 2 3 4 5 6 7 8 9 } (2) \left\{ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} \right\} \tag{2} 147258369(2)

树形图

找了一些实用模板。

  1. 普通树状图
\documentclass[border=10pt]{standalone} \usepackage{verbatim}\begin{comment}
:Title: A simple Tree
\end{comment}\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[sibling distance=10em,every node/.style = {shape=rectangle, rounded corners,draw, align=center,top color=white, bottom color=blue!20}]]\node {Formulas}child { node {single-line} }child { node {multi-line}child { node {aligned at}child { node {relation sign} }child { node {several places} }child { node {center} } }child { node {first left,\\centered,\\last right} } };
\end{tikzpicture}
\end{document}

在这里插入图片描述
2. 决策树

\documentclass[border=10pt]{standalone} 
\usepackage{verbatim}\begin{comment}
:Title: Decision tree\end{comment}
\usepackage{tikz}
\tikzset{treenode/.style = {shape=rectangle, rounded corners,draw, align=center,top color=white, bottom color=blue!20},root/.style     = {treenode, font=\Large, bottom color=red!30},env/.style      = {treenode, font=\ttfamily\normalsize},dummy/.style    = {circle,draw}
}
\begin{document}\begin{tikzpicture}[grow                    = right,sibling distance        = 6em,level distance          = 10em,edge from parent/.style = {draw, -latex},every node/.style       = {font=\footnotesize},sloped]\node [root] {Formula}child { node [env] {equation}edge from parent node [below] {single-line?} }child { node [dummy] {}child { node [dummy] {}child { node [env] {align\\flalign}edge from parent node [below] {at relation sign?} }child { node [env] {alignat}edge from parent node [above] {at several}node [below] {places?} }child { node [env] {gather}edge from parent node [above] {centered?} }edge from parent node [below] {aligned?} }child { node [env] {multline}edge from parent node [above, align=center]{first left,\\centered,}node [below] {last right}}edge from parent node [above] {multi-line?} };\end{tikzpicture}
\end{document}

在这里插入图片描述
3. 文件树


\documentclass{minimal}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\begin{comment}
:Title: Filesystem tree
\end{comment}
\usetikzlibrary{trees}
\begin{document}\tikzstyle{every node}=[draw=black,thick,anchor=west]\tikzstyle{selected}=[draw=red,fill=red!30]\tikzstyle{optional}=[dashed,fill=gray!50]\begin{tikzpicture}[%grow via three points={one child at (0.5,-0.7) andtwo children at (0.5,-0.7) and (0.5,-1.4)},edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]\node {texmf}child { node {doc}}		child { node {fonts}}child { node {source}}child { node [selected] {tex}child { node {generic}}child { node [optional] {latex}}child { node {plain}}}child [missing] {}				child [missing] {}				child [missing] {}				child { node {texdoc}};\end{tikzpicture}
\end{document}

在这里插入图片描述

页边距

\usepackage{geometry}
\geometry{a4paper,left=2cm,right=2cm,top=2cm,bottom=2cm}

总结:
层次结构大概梳理:

\begin{document}\section{1}\subsection{1.1}\paragraph{}\begin{enumerate}\begin{tacular}

尾声
到这里一份朴实无华的pdf就制作完成了,基本的功能已经具备。后面有更多的需求再补充。

这篇关于LaTeX入门——制作一份朴实无华的pdf文档的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/407921

相关文章

Java操作Word文档的全面指南

《Java操作Word文档的全面指南》在Java开发中,操作Word文档是常见的业务需求,广泛应用于合同生成、报表输出、通知发布、法律文书生成、病历模板填写等场景,本文将全面介绍Java操作Word文... 目录简介段落页头与页脚页码表格图片批注文本框目录图表简介Word编程最重要的类是org.apach

从入门到精通MySQL联合查询

《从入门到精通MySQL联合查询》:本文主要介绍从入门到精通MySQL联合查询,本文通过实例代码给大家介绍的非常详细,需要的朋友可以参考下... 目录摘要1. 多表联合查询时mysql内部原理2. 内连接3. 外连接4. 自连接5. 子查询6. 合并查询7. 插入查询结果摘要前面我们学习了数据库设计时要满

从入门到精通C++11 <chrono> 库特性

《从入门到精通C++11<chrono>库特性》chrono库是C++11中一个非常强大和实用的库,它为时间处理提供了丰富的功能和类型安全的接口,通过本文的介绍,我们了解了chrono库的基本概念... 目录一、引言1.1 为什么需要<chrono>库1.2<chrono>库的基本概念二、时间段(Durat

解析C++11 static_assert及与Boost库的关联从入门到精通

《解析C++11static_assert及与Boost库的关联从入门到精通》static_assert是C++中强大的编译时验证工具,它能够在编译阶段拦截不符合预期的类型或值,增强代码的健壮性,通... 目录一、背景知识:传统断言方法的局限性1.1 assert宏1.2 #error指令1.3 第三方解决

springboot项目打jar制作成镜像并指定配置文件位置方式

《springboot项目打jar制作成镜像并指定配置文件位置方式》:本文主要介绍springboot项目打jar制作成镜像并指定配置文件位置方式,具有很好的参考价值,希望对大家有所帮助,如有错误... 目录一、上传jar到服务器二、编写dockerfile三、新建对应配置文件所存放的数据卷目录四、将配置文

Python Pillow 库详解文档(最新推荐)

《PythonPillow库详解文档(最新推荐)》Pillow是Python中最流行的图像处理库,它是PythonImagingLibrary(PIL)的现代分支和继承者,本文给大家介绍Pytho... 目录python Pillow 库详解文档简介安装核心模块架构Image 模块 - 核心图像处理基本导入

从入门到精通MySQL 数据库索引(实战案例)

《从入门到精通MySQL数据库索引(实战案例)》索引是数据库的目录,提升查询速度,主要类型包括BTree、Hash、全文、空间索引,需根据场景选择,建议用于高频查询、关联字段、排序等,避免重复率高或... 目录一、索引是什么?能干嘛?核心作用:二、索引的 4 种主要类型(附通俗例子)1. BTree 索引(

Redis 配置文件使用建议redis.conf 从入门到实战

《Redis配置文件使用建议redis.conf从入门到实战》Redis配置方式包括配置文件、命令行参数、运行时CONFIG命令,支持动态修改参数及持久化,常用项涉及端口、绑定、内存策略等,版本8... 目录一、Redis.conf 是什么?二、命令行方式传参(适用于测试)三、运行时动态修改配置(不重启服务

MySQL DQL从入门到精通

《MySQLDQL从入门到精通》通过DQL,我们可以从数据库中检索出所需的数据,进行各种复杂的数据分析和处理,本文将深入探讨MySQLDQL的各个方面,帮助你全面掌握这一重要技能,感兴趣的朋友跟随小... 目录一、DQL 基础:SELECT 语句入门二、数据过滤:WHERE 子句的使用三、结果排序:ORDE

Python中图片与PDF识别文本(OCR)的全面指南

《Python中图片与PDF识别文本(OCR)的全面指南》在数据爆炸时代,80%的企业数据以非结构化形式存在,其中PDF和图像是最主要的载体,本文将深入探索Python中OCR技术如何将这些数字纸张转... 目录一、OCR技术核心原理二、python图像识别四大工具库1. Pytesseract - 经典O