【LaTeX】--- 入門篇

LaTeX\LaTeX{}



一. LaTeX\LaTeX{}基本架構

LaTeX結構圖

二. LaTeX\LaTeX{}細化內容

2.1. 註釋

LaTeX\LaTeX{}中的行註釋符是%

若想在文檔中顯示%, 可以通過加斜槓的方式: \%

多行註釋的話需要使用額外的包verbatim, 如下

\documentclass{article}
\usepackage{verbatim}

\begin{document}
    \begin{comment}
    Multi-line comment content
    Multi-line comment content
    Multi-line comment content
    \end{comment}
\end{document}

2.2. 文檔序言

2.2.1. 序言定義

\begin{document} 之前輸入的都稱爲序言, 序言定義了文檔的類型、文檔使用到的包、文檔語言、文檔顯示效果

2.2.2. 文檔類型定義

設置字體大小爲12pt,
設置紙張大小爲letterpaper

\documentclass[12pt, letterpaper]{article}

2.2.3. 中英文文檔

2.2.3.1. 純英文文檔

\documentclass[12pt, letterpaper]{article}

2.2.3.2. 包含了中文的文檔

\documentclass[UTF8]{cteart}

2.3. 標題、作者、日期

必須在主體beginend之間添加\maketitle才能顯示添加的信息

2.3.1. 添加標題

\documentclass{article}
\title{LaTeX Learning}

\begin{document}
	\maketitle
	Hello, \LaTeX{}!
\end{document}

2.3.2. 添加作者

\documentclass{article}
\title{LaTeX Learning}
\author{Tomas Yang}

\begin{document}
	\maketitle
	Hello, \LaTeX{}!
\end{document}

2.3.3. 添加日期

2.3.3.1. 使用當前日期

編譯後顯示編譯時刻的日期

\documentclass{article}
\title{LaTeX Learning}
\author{Tomas Yang}
\date{\today}

\begin{document}
	\maketitle
	Hello, \LaTeX{}!
\end{document}

2.3.3.2. 使用自定義日期

\documentclass{article}
\title{LaTeX Learning}
\author{Tomas Yang}
\data{December 2019}

\begin{document}
	\maketitle
	Hello, \LaTeX{}!
\end{document}

效果圖:
LaTeX效果圖

2.4. 主體內容

位於beginend之間的內容

2.4.1. 字體效果

2.4.1.1. 粗體字

textbf{}, 括號內爲加粗內容

2.4.1.2. 斜體字

textit{}, 括號內爲加粗內容

自適應斜體字的話是根據文字的內容自動判斷是斜體還是非斜體, 使用方法是 \emph{}, 括號內爲加粗內容

2.4.1.3. 下劃線

underline{}, 括號內爲下劃線內容

2.4.2. 列表

2.4.2.1. 無序列表

\documentclass{article}

\begin{document}
    \begin{itemize}
    \item 123456789
    \item 987654321
    \end{itemize}
\end{document}

2.4.2.2. 有序列表

\documentclass{article}

\begin{document}
    \begin{enumerate}
    \item 123456789
    \item 987654321
    \end{enumerate}
\end{document}

2.4.3. 數學公式

2.4.3.1. 行內模式

數學公式存在於段落之間

\documentclass{article}

\begin{document}
    In physics, $E=mc^2$ is very important.
\end{document}

2.4.3.2. 行間模式

單獨成爲一行的數學公式

\documentclass{article}

\begin{document}
    In physics, this is very important.
    
    $$E=mc^2$$ 
\end{document}

2.4.4. 圖片

2.4.4.1. 上傳圖片

待上傳的照片testLaTex.jpg.tex在同一個目錄下

\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {images/} }

\begin{document}
	\includegraphics[scale=0.4]{testLaTeX.jpg}
	%\includegraphics[width=5cm, height=5cm]{testLaTeX.jpg}
\end{document}

2.4.4.2. 圖片放置位置控制(使用figure環境)

首先交代控制參數:

符號 動作
h here, 表示在源碼對應位置處插入圖像
t top, 表示在頁頂部插入圖像
b bottom, 表示在頁底部插入圖像
p page, 表示單獨一頁插入圖像

使用方法:

\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {images/} }

\begin{document}
    We can see some examples.
    \begin{figure}[h]
        %居中顯示
        \centering
        \includegraphics[width=0.25\textwidth]{testLaTeX.jpg}
        % 圖像的標題
        \caption{Test LaTeX}
        %在文檔中引用圖片,用這個命令設置一個標籤。標籤自動對圖像進行編號,並允許您引用它
        \label{fig:mesh1}
    \end{figure}

    % \ref{fig:mesh1}引用標籤號
    As we showed in \ref{fig:mesh1}.
\end{document}

2.4.5. 超鏈接

爲了引入超鏈接的使用, 需要使用hyperref包,
其中:

  • \url{} 是直接插入地址, 即在正文中也顯示爲網絡地址
  • \href{}{} 則插入地址, 但在正文中可以顯示爲其他字樣
\documentclass{article}
\usepackage{hyperref}

\begin{document}
    \url{https://www.baidu.com}
    
    \href{https://www.baidu.com}{baidu}
\end{document}

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