Latex 格式(Format)

Latex 格式(Format) 首页 / Latex入门教程 / Latex 格式(Format)

格式参数用于为文件或文档提供独特的样式,有多种格式化文档的方法,如下所列:

可选参数

流行的可选参数是:

  • twocolumn    -  这是2列页面
  • titlepage         -  \maketitle 生成标题页
  • openright      - 如果使用了两个侧面,则本章从右侧页面开始
  • landscape      -  用于在横屏中显示
  • legno               -  将等式编号放在左侧
  • flegn                -  左对齐方程式与中心对齐
  • twoside          -  会打印在纸张的两面。

a)Class

      此处使用的文档类型是演讲稿和科学期刊中的文章,报告,书籍,幻灯片,海报程序(基于文章类别的类),信件,投影仪(用于撰写演讲稿)等。

该类在程序开始时使用, {article} 是常用的类。

      文档类定义了文档的总体布局。

      其他类也包含在大括号中,如下所示:

  • report   -  用于包含较长文档的章节。
  • thesis   -  用于使用Latex准备论文。
  • letter    -  用于撰写信件
  • books   -  书籍
  • slides   -  用于透明胶片。

b)Groups

      为了限制参数并将状态限制在局部,可以将特定部分局部括在花括号中。但是在某些情况下,如果无法使用括号,则可以分别使用\bgroup \egroup 来开始和结束一个组。

      例如,普通文本{xyz}更多普通文本

      可以写为普通文本\bgroup xyz\egroup {}更多普通文本

c)Packages

      它是一种为文档提供或添加额外格式设置函数的方法,例如图片,书目和链接。它还为Latex添加了新函数。所有软件包必须仅包含在序言中。要加载软件包,使用的命令是:

\usepackage{packagename}

它也可以用作\usepackage [options] {package}

一些常用的软件包是:

  • color         -  提供了一种使用颜色的方法。
  • rotating   -  用于旋转,尤其是图形和表格。
  • fancyhdr  -  它自定义页眉和页脚。
  • graphicx  - 是用于包含图形的命令。
  • setspace  - 这是一种更改行距的简便方法。

结构格式

  • Title

标题用于信函,文章,报告,书类等大多数纸张格式中。要创建标题,需要指定作者,标题和日期的文本,然后使用\maketitle 命令,标题页由Latex生成。 \begin {document} 必须在开始时使用。用于创建标题的命令是\maketitle 。创建标题的代码如下:

\documentclass[12pt]{article}
    \begin{document}
        \title{This is my website Learnfk} % 定义标题
        \author{ The author learnfk}  % 定义作者信息
        \date{ 2021-12-12 } % 定义日期
        \maketitle
    \end{document}

输出如下图所示:

Latex FORMATS

如果您根本不需要日期,则可以使用\date {} 命令。

要显示当前日期,可以使用\date {\today} 命令。

Sections : 您可以将文档分为多个部分和子部分。用于创建这些部分的命令是:
  • \section{..}
  • \subsection{..}
  • \subsubsection{..}
  • \paragraph{..}
  • \subparagraph{..}

这些是articles类的常用命令。您还可以对书籍和报告类别使用\chapter {..} 命令。

以下部分的代码如下:

\documentclass[12pt]{article}
    \begin{document}
        \title{This is my WebSite LearnFK} 
        \author{ My name is LearnFk} 
        \date{\today }
        \maketitle
        \section{Introduction}
            Learnfk is a tutorial network for programmers technology introduction
        \section{About}
            Including PHP, Java, Latex, Linux
            \subsection{}
                The first part of the method.
            \subsection{}
                The second part of the method.
        \section{Results}
        This is the section for the results
    \end{document}

输出如下图所示:

Latex FORMATS
  • Labeling 要引用文档的其他部分,可以标记任何section命令。您可以使用\label {labelname}标记该部分。 如果要参考标签的章节或页码;您可以使用\ref {labelname}和\pageref {labelname}。 代码如下所示:
\documentclass[12pt]{article}
    \begin{document}
        \title{This is my WebSite LearnFK} 
        \author{ My name is LearnFk} 
        \date{\today }
        \maketitle
        \section{Introduction}
            Learnfk is a tutorial network for programmers technology introduction
        \section{About}
            Including PHP, Java, Latex, Linux
            \subsection{}
                \label{sec1}
                The first part of the method.
            \subsection{}
                The second part of the method.
        \section{Results}
        This is the section for the results. You can refer to the section \ref{sec1} on page \pageref{sec1}.
    \end{document}

输出

Latex FORMATS

对于多页或文件,您可以根据需要轻松地参考页码和部分。

  • Table of contents

如果要在文档中创建目录,可以键入命令\tableofcontents

  • Page Numbering

此格式用于在编写文档之前对页进行编号。它还可以确保主文档从第1页开始。可以在罗马和阿拉伯语之间切换页码。用于对页面进行编号的命令是\pagenumbering {..} ,该命令在\maketitle 命令之后声明。

上述方法的代码如下:

\documentclass[12pt]{article}
    \begin{document}
        \title{This is my WebSite LearnFK} 
        \author{ My name is LearnFk} 
        \date{\today }
        \maketitle
        
        \pagenumbering{roman}  %页码编号使用字体
        
        \tableofcontents %创建目录
        \newpage
    \end{document}

输出如下图所示:

Latex FORMATS

。页眉和页脚(Headers and Footers)

      出现在头部或脚部。输出屏幕包括头部,身体和脚。默认情况下,除字母外的所有类别均打印页码。

      要修改默认操作,可以使用\pagestyle 命令(位于\chapter 之后)或类似的命令。

标准页面样式的类型如下:

  • \pagestyle {plain}                 -  这是报表类和文章的默认样式。页头列出在脚上,而头是空的。
  • \pagestyle {headings}         -  在这种样式中,脚是空的。标题和页码放在标题中。
  • \pagestyle {myheadings}   -  指定头部使用的信息;使用以下命令。
\markboth{leftheader}{rightheader}
\markright{rightheader}

\markboth 用于双面文件或文档,而\markright 用于双面文档。

  • \pagestyle {empty}        -  这种样式的页眉和脚都是空的。
  • \thispagestyle {style}    -  它仅用于更改当前页面的样式。例如,\thispagestyle {empty} 用于手脚没有任何东西。此命令将仅在当前页面上执行,而不会影响其他页面。

如果要以其他方式格式化或自定义页眉和页脚。您可以使用 fancyhdr 命令。 Latex中的此命令用作\usepackage {fancyhdr} 。此处使用的包可以使页眉和页脚在左侧,右侧和中心对齐。您还可以定义多行标题和过滤器,用于偶数和奇数页的单独标题等。

\pagestyle {fancy} 也用于此处。

      {}(大括号)中可以包含以下命令:\lhead {},\chead {},\head {},\foot {},\foot {},\rfoot {} 。

      如果要隐藏默认情况下绘制的标题下的水平线,可以使用\renewcommand {\headrulewidth} {0pt} 命令。

。Margins

这些命令用于手动设置边距。默认情况下,内部页边距被视为 1英寸。因此,如果要将边距设置为 0.5 英寸,则必须提及该边距 -0.5 英寸。您还可以使用 textheight textwidth 命令设置文本区域的高度和宽度。

下表中给出了设置边距的可用命令:

边距命令
左页边距 (如果使用单面,则为奇数页) \oddsidemargin
左页边距 (如果使用双面,则为偶数页面) \evensidemargin
右边距 \textwidth
上边距 \topmargin
底边距 \textheight

用于设置页边距英寸的命令为:

  • 要将上边距设置为0.7英寸,请\setlength {\topmargin} {-0.7in}
  • 要在右侧页面上将页边距设置为1英寸,请\setlength {\oddsidemargin} {0in}
  • 要在双面文档的左侧页面上将页边距设置为1英寸,请\setlength {\evensidemargin} {0in}
  • 要保留右边距的空间,请\setlength {\textwidth} {0in}
  • 要为文本保留9英寸,\setlength {\textheight} {9in}

。Paragraph

要开始一个段落,可以使用控制顺序\par ,也可以保留空白。该段落的缩进默认为1.5em(是当前字体的磅值的1.5倍)。段落之间没有插入多余的空间。要控制段落的分隔和缩进,使用命令\parindent 和\ parskip 。让我们考虑以下示例:

本示例包含一个简单的段落。代码如下:

\documentclass[12pt]{article}
    \begin{document}
        \title{This is my WebSite LearnFK} 
        \author{ My name is LearnFk} 
        \date{\today }
        \maketitle
        
       Learnfk is a tutorial network for programmers technology introduction, including PHP, Java,
        Latex, Linux and other related \newline  tutorials
    \end{document}

输出如下图所示:

Latex FORMATS

本示例包含一个带有段落分隔和缩进命令的段落。代码如下:

本示例包含一个简单的段落。代码如下:

\documentclass[12pt]{article}
    \begin{document}
        \title{This is my WebSite LearnFK} 
        \author{ My name is LearnFk} 
        \date{\today }
        \maketitle
        \parindent=3in %缩进
        \parskip=15pt %与上方的距离
        
        Learnfk is a tutorial network for programmers technology introduction, including PHP, Java,
        Latex, Linux and other related  tutorials
        
        \parindent=0in
        \parskip=30pt
        This is the topic of learnfk
    \end{document}

输出如下图所示:

Latex FORMATS

您会注意到上面两个示例之间的区别。

i。References

也称为交叉引用,用于截面,图形,方程式或表格。使用的命令如下:

  • \pageref {marker}  -  它包含与\label 命令相关的页码。
  • \label {marker}        -  用于设置标记以备将来参考。
  • \ref {marker}            -  由与\label 命令相关的部分,图形等组成。

绘制规则

Latex FORMATS

如果要在文档页面上绘制水平或垂直线,可以使用\rule 命令。在Latex中,它将写为:

\rule[lift]{width}{height}

提升是可选参数,它是提高到基线以上的量。宽度是水平尺寸,高度是垂直尺寸。例如,如果要绘制下面给出的线:

您可以使用\rule {\textwidth} {2pt} 命令。

上面示例的代码或程序如下:

\documentclass[12pt]{article}
    \begin{document}
        \title{This is my WebSite LearnFK} 
        \author{ My name is LearnFk} 
        \date{\today }
        \maketitle
        
        \rule{\textwidth}{1pt}
        
        \section{Introductino}
            Learnfk is a tutorial network for programmers technology introduction
        \section{Methods}
            Including PHP, Java,
        Latex, Linux and other related  tutorials
        \subsection{}
            \label{sec1}
            This first part of the Method
        \subsection{}
            This Seond part of the method \ref{sec1} on page \pageref{sec1}.
     
    \end{document}hod.
\end{document}

输出如下图所示:

Latex FORMATS

您可以根据要求绘制多条线。

例如,要绘制两条线,代码如下:

\documentclass[12pt]{article}
    \begin{document}
        \title{This is my WebSite LearnFK} 
        \author{ My name is LearnFk} 
        \date{\today }
        \maketitle
        
        \rule{\textwidth}{1pt}
        
        \section{Introductino}
            Learnfk is a tutorial network for programmers technology introduction
        \section{Methods}
            Including PHP, Java,
        Latex, Linux and other related  tutorials
        \subsection{}
            \label{sec1}
            This first part of the Method
        \subsection{}
            This Seond part of the method \ref{sec1} on page \pageref{sec1}.
     
        \rule{\textwidth}{2pt}
    \end{document}

下图显示了以上示例的输出:

Latex FORMATS
  • Footnotes   -   Latex会自动为脚注编号。命令 \footnote恰好位于您希望脚注出现的位置。 \footnote 命令与其前面的文本之间不应有多余的空格。该命令写为\footnote {注释文本在此处编写}。 大括号内的文本显示在底部。例如,考虑以下代码:
\documentclass[12pt]{article}
    \begin{document}
        \title{This is my WebSite LearnFK} 
        \author{ My name is LearnFk} 
        \date{\today }
        \maketitle
        \rule{\textwidth}{1pt}
        
        Learnfk is a tutorial network for programmers' technical introduction, \footnote{ LearnFk.com } including PHP, Java, Latex, Linux and other related tutorials \footnote{ LearnFK Tutorials}. Welcome, study hard, day day up! \footnote{ Thanks !}
    \end{document}

输出如下图所示:

Latex FORMATS

脚注将出现在底部。对于上面的示例,脚注如下图所示:

链接:https://www.learnfk.comhttps://www.learnfk.com/latex/latex-formats.html

来源:LearnFk无涯教程网

Latex FORMATS
  • Centering    -  如果您只在中心放置一条线;那么您可以使用\centerline 命令。例如, \centerline {此处提到的行将显示在中心}。 让我们考虑以下示例:
\documentclass[12pt]{article}
    \begin{document}
        \title{This is my WebSite LearnFK} 
        \author{ My name is LearnFk} 
        \date{\today }
        \maketitle
        \rule{\textwidth}{1pt}
        
        Learnfk is a tutorial network for programmers' technical introduction, \footnote{ LearnFk.com } including PHP, Java, Latex, Linux and other related tutorials \footnote{ LearnFK Tutorials}.\\\\ %\\ 相当于\newline 换行
        \centerline{Welcome, study hard, day day up!}   %centerline 用于居中显示
    \end{document}

输出如下图所示:

Latex FORMATS

如果要显示多行,则可以按以下方式编写。

\begin{center}
.........
\end{center}
  • Quotations    -   引号可以在以下环境中使用:
\begin{quote}
..........
\end{quote}

在段落中,节中的引号之间没有空白行分隔和意图。

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

编辑训练营 -〔总编室〕

Node.js开发实战 -〔杨浩〕

深入浅出云计算 -〔何恺铎〕

基于人因的用户体验设计课 -〔刘石〕

零基础实战机器学习 -〔黄佳〕

零基础入门Spark -〔吴磊〕

深入C语言和程序运行原理 -〔于航〕

业务开发算法50讲 -〔黄清昊〕

云原生基础架构实战课 -〔潘野〕

好记忆不如烂笔头。留下您的足迹吧 :)