無涯教程 - 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

腳註將出現在底部。對於上面的示例,腳註如下圖所示:

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}

在段落中,節中的引號之間沒有空白行分隔和意圖。

 

https://www.learnfk.com/latex/latex-formats.html

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章