文章目录
LaTeX
送柴侍御(唐 - 王昌龄)
沅水通波接武冈,送君不觉有离伤。
青山一道同云雨,明月何曾是两乡。
Latex中的命令格式: \CommandName[Optional Argument]{Compulsory Argument}
或
\CommandName{Compulsory Argument}[Optional Argument]
.
环境格式: \begin{environment}...\end{environment}
.
环境准备
需要:
- Tex Distribution
- LaTex Editor
Tex Distribution:
- TeX Live
- MikTex
LaTeX Editor:
- Texworks Editor
- Texnic Center
- Tex Studio
有用的网站: tex.stackexchange.com
.
基本结构
\documentclass{article}
\begin{document}
<main text of the document>
\noindent Hello! \LaTeX{}\\
Latex is a typesetting system.
\end{document}
文档类型和命令的使用
\documentclass{...}
% 这是注释
% \documentclass - 指出文档的类型
% \documentclass[options]{name of class}
% name of class 的选项是:
% article - 短的文章如报告、论文等
% report - 报告 exam - 考试或测验
% letter - 信件 book - 书籍
% beamer slides
% \documentclass 和 \begin{document} 之间的是 preamble
% preamble 是正文之前的配置
% \usepackage 的使用
% \usepackage[options]{name of package}
\usepackage[hmargin=1in,vmargin=1in]{geometry}
\usepackage{comment} % 多行注释
\begin{document}
% 下面是多行注释
\begin{comment}
A first line of comment.
A second line of comment.
\end{comment}
\end{document}
% 信件
\documentclass{letter}
\signature{Your name}
\address{From: \\Line 1 \\ Line 2 \\ Line 3}
\begin{document}
\begin{letter}{To:\\ Line 1 \\ Line 2 \\ Line 3}
\opening{Dear Sir\textbackslash Madam,}
This is content part.
\closing{Yours Faithfully,}
\ps{P.S. Here goes your ps.}
\encl{Enclosures.}
\end{letter}
\end{document}
% 研究类的文章
\documentclass[letterpaper]{article}
\usepackage{geometry,url,graphicx}
\title{A Sample Research Paper}
\author{X Y Z}
\date{dd-mm-yyyy}
\begin{document}
\maketitle
\abstract{An abstract}
\newpage
\tableofcontents
\newpage
\listoftables
\newpage
\section{Introduction}
An Introduction.
\section{Background and Preliminary}
A Background and Preliminary.
\section{First Main Section}
A first section.
\subsection{Subsection of I Section}
A subsection.
\subsection{Another Subsection of I Section}
Another subsection.
\section{Second Main Section}
A second section.
\subsection{Subsection of II Section}
A subsection.
\subsection{Another Subsection of II Section}
Another subsection.
\section{Conclusion}
A Conclusion
\newpage
\begin{thebibliography}{99}
\bibitem{Ref1} Author 1., \textit{Book 1}, Publisher 1, Year 1.
\bibitem{Ref2} Author 2., \textit{Book 2}, Publisher 2, Year 2.
\end{thebibliography}
\end{document}
\documentclass[letterpaper,11pt]{article}
\usepackage[hmargin=1in,vmargin=1in]{geometry}
\usepackage{amsmath}
\pagestyle{empty}
\begin{document}
Math Quiz \hspace{1in} Name: \hrulefill
\begin{enumerate}
\item Suppose that $ax^2+bx+c=0$. Show that
\begin{displaymath}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} ~.
\end{displaymath}\vspace{0.75in}
\item Solve the following system of equations:
\begin{align*}
2x - 4y ~&=~ \sum_{n=0}^1 \ln \left( e^3 \right)\\
3x + 5y ~&=~ \int_0^1 2x\;dx ~+~ \lim_{x \to -\infty} \frac{\sin x}{\sqrt[3]{x}}
\end{align*}\vspace{2in}
\item Draw a right triangle $\triangle ABC$ with $C = 90^{\circ}$.\vspace{1in}
\item Answer the following questions about the function $f(\theta) = \cos \theta$:
\begin{enumerate}
\item What is $f^\prime(\theta)$?\vspace{0.75in}
\item What is $\lim_{\theta \to 0} f(\theta)$?
\end{enumerate}
\end{enumerate}
\end{document}
\documentclass[addpoints,12pt]{exam}
% \pointsinmargin
\pointsinrightmargin
\begin{document}
\begin{questions}
\question[10] I question
\question
\begin{parts}
\part[5] I sub-section
\part[5] II sub-section
\part
\begin{subparts}
\subpart[3] I sub-question in (c)
\subpart[2] II sub-question in (c)
\end{subparts}
\end{parts}
\question[15] II question
\question[2] The correct option
\begin{choices}
\choice I Option
\choice II Option
\choice III Option
\choice IV Option
\end{choices}
\question[2] The correct option \\
\begin{oneparchoices}
\choice I Option
\choice II Option
\choice III Option
\choice IV Option
\end{oneparchoices}
\question[2] The correct option \\
\begin{checkboxes}
\choice I Option
\choice II Option
\choice III Option
\choice IV Option
\end{checkboxes}
\end{questions}
\end{document}
\documentclass[addpoints]{exam}
\usepackage{amssymb}
\checkboxchar{\(\Box \)}
\pointsinrightmargin
\begin{document}
% \fillin: fill in the blank questions
% \begin{solution}...\end{solution}
% \printanswers \noprintanswers
\begin{questions}
\question[2] The correct option
\begin{checkboxes}
\choice I Option
\choice II Option
\choice III Option
\choice IV Option
\end{checkboxes}
\question[2] The correct option \\
\begin{oneparchoices}
\choice I Option
\choice II Option
\choice III Option
\choice IV Option
\end{oneparchoices}
\end{questions}
\end{document}
内容层次
Content Part | Level |
---|---|
Part | -1 |
Chapter | 0 |
Section | 1 |
Subsection | 2 |
Subsection | 3 |
Paragraph | 4 |
Subparagraph | 5 |
\part
和\chapter
只对文档类型为book
或report
的文档有用.
% 内容层次
\tableofcontents % 目录
\section{First section}
\section{Second section}
\subsection{A sub-section in II section}
\subsubsection[Deeper level]{A sub-section at deeper level}
\section{Third section}
\subsection{A subsection in III section}
\subsection{Another subsection in III section}
文本内容和排版
% \\ 换行 \newline 换行 \newpage 新的一页
% 通过空行或\par 开始新的段落
% 多个空格等价于一个空格 多个空白行等价于单行(空白折叠)
% '\'+' ' 等价于 一个空格
% 特殊字符
% 可使用\symbol{...}显示特殊字符, 要引入 \usepackage[T1]{fontenc}
% \ - \textbackslash
% %-\% $-\$ #-\# &-\& {-\{ }-\} _-\_
% {(left brace) - \symbol{123}
% }(right brace) - \symbol{125}
% _(underscore) - \symbol{95}
% ^(caret) - \symbol{94}
% ~(tilde) - \symbol{126}
% \copyright \textendash \textemdash \textregistered \texttrademark
% 字体
\texttt{Typewriter Font} % Monospaced
\textsf{Serif Font} % Sans serif
\textrm{Roman Font}
% 文本排版(Text formatting)
% 字体样式
% bold(粗体) - \textbf{...} italic(斜体) - \emph{...} or \textit
% bold italic - \textbf{\emph{...}} slanted - \textsl{Slanted text}
% underline(下划