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

相关文章

Python如何实现PDF隐私信息检测

《Python如何实现PDF隐私信息检测》随着越来越多的个人信息以电子形式存储和传输,确保这些信息的安全至关重要,本文将介绍如何使用Python检测PDF文件中的隐私信息,需要的可以参考下... 目录项目背景技术栈代码解析功能说明运行结php果在当今,数据隐私保护变得尤为重要。随着越来越多的个人信息以电子形

使用Python快速实现链接转word文档

《使用Python快速实现链接转word文档》这篇文章主要为大家详细介绍了如何使用Python快速实现链接转word文档功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 演示代码展示from newspaper import Articlefrom docx import

浅析如何使用Swagger生成带权限控制的API文档

《浅析如何使用Swagger生成带权限控制的API文档》当涉及到权限控制时,如何生成既安全又详细的API文档就成了一个关键问题,所以这篇文章小编就来和大家好好聊聊如何用Swagger来生成带有... 目录准备工作配置 Swagger权限控制给 API 加上权限注解查看文档注意事项在咱们的开发工作里,API

使用Python实现批量分割PDF文件

《使用Python实现批量分割PDF文件》这篇文章主要为大家详细介绍了如何使用Python进行批量分割PDF文件功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录一、架构设计二、代码实现三、批量分割PDF文件四、总结本文将介绍如何使用python进js行批量分割PDF文件的方法

使用Python实现PDF与SVG互转

《使用Python实现PDF与SVG互转》SVG(可缩放矢量图形)和PDF(便携式文档格式)是两种常见且广泛使用的文件格式,本文将详细介绍如何使用Python实现SVG和PDF之间的相互转... 目录使用工具使用python将SVG转换为PDF使用Python将SVG添加到现有PDF中使用Python将PD

C#提取PDF表单数据的实现流程

《C#提取PDF表单数据的实现流程》PDF表单是一种常见的数据收集工具,广泛应用于调查问卷、业务合同等场景,凭借出色的跨平台兼容性和标准化特点,PDF表单在各行各业中得到了广泛应用,本文将探讨如何使用... 目录引言使用工具C# 提取多个PDF表单域的数据C# 提取特定PDF表单域的数据引言PDF表单是一

python实现pdf转word和excel的示例代码

《python实现pdf转word和excel的示例代码》本文主要介绍了python实现pdf转word和excel的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价... 目录一、引言二、python编程1,PDF转Word2,PDF转Excel三、前端页面效果展示总结一

基于C#实现PDF文件合并工具

《基于C#实现PDF文件合并工具》这篇文章主要为大家详细介绍了如何基于C#实现一个简单的PDF文件合并工具,文中的示例代码简洁易懂,有需要的小伙伴可以跟随小编一起学习一下... 界面主要用于发票PDF文件的合并。经常出差要报销的很有用。代码using System;using System.Col

Java操作PDF文件实现签订电子合同详细教程

《Java操作PDF文件实现签订电子合同详细教程》:本文主要介绍如何在PDF中加入电子签章与电子签名的过程,包括编写Word文件、生成PDF、为PDF格式做表单、为表单赋值、生成文档以及上传到OB... 目录前言:先看效果:1.编写word文件1.2然后生成PDF格式进行保存1.3我这里是将文件保存到本地后

通过C#获取PDF中指定文本或所有文本的字体信息

《通过C#获取PDF中指定文本或所有文本的字体信息》在设计和出版行业中,字体的选择和使用对最终作品的质量有着重要影响,然而,有时我们可能会遇到包含未知字体的PDF文件,这使得我们无法准确地复制或修改文... 目录引言C# 获取PDF中指定文本的字体信息C# 获取PDF文档中用到的所有字体信息引言在设计和出