Created
March 17, 2016 07:32
-
-
Save Liam0205/1d8224192c6a6761e9db to your computer and use it in GitHub Desktop.
什么破模板……
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %!TEX TS-program = xelatex | |
| \documentclass[a4paper,titlepage, UTF8, hyperref]{ctexart} | |
| \usepackage{hyperref} | |
| \hypersetup{hidelinks} | |
| \usepackage{graphicx} | |
| \usepackage{titlesec, titletoc} %设置标题格式 | |
| \usepackage{wrapfig} | |
| \usepackage{fancyhdr} %页眉页脚 | |
| \usepackage{upgreek} %\upalpha等可生成直立希腊字 | |
| \usepackage{ifthen} | |
| \usepackage{longtable} | |
| \usepackage{listings} %代码排版 | |
| \usepackage{color} %代码排版背景颜色 | |
| \usepackage[labelfont=bf,up, | |
| textfont=it,up]{caption} | |
| \usepackage{subcaption} | |
| \usepackage{amsmath} | |
| \definecolor{gray}{rgb}{0.9,0.9,0.9} | |
| \definecolor{shadecolor}{gray}{0.85} | |
| \lstset{aboveskip=.8em, | |
| xleftmargin=1em, | |
| xrightmargin=1em} | |
| %设置各字体 | |
| \setCJKmonofont{KaiTi} | |
| \setmainfont[Mapping=tex-text]{Times New Roman} | |
| \setsansfont{Arial} | |
| \setmonofont{Consolas} | |
| \newcommand{\HRule}{\rule{\linewidth}{0.5mm}} | |
| \newcommand{\HUGE}{\fontsize{29pt}{29pt}\selectfont} | |
| \titleformat{\contents}{\Huge\bfseries}{\vspace{0.3cm}\hspace{-0.8cm}}{1em} {} | |
| \titleformat{\section}{\Huge\bfseries}{\vspace{0.3cm}\hspace{-0.8cm}}{1em} {} | |
| \titleformat{\subsection}{\Large\bfseries}{\arabic{subsection}.}{1em} {\vspace{.2em}} | |
| \titleformat{\subsubsection}{\large\bfseries}{\arabic{subsection}.\arabic{subsubsection}}{1em} {\vspace{.1em}} | |
| \headheight=13pt | |
| % 本文档自定义变量 | |
| \newcommand{\splitsubfigwidth}{0.45\textwidth} | |
| \newcommand{\splitgraphicwidth}{\textwidth} | |
| \newcommand{\subfigvspace}{1em} | |
| \newcommand{\subfighspace}{1em} | |
| \begin{document} | |
| \begin{titlepage} | |
| % 首行的位置往上调整。但vspace前面需要有东西才会起效。 | |
| \phantom{Start!} | |
| \vspace{-1.7cm} | |
| \begin{flushleft} | |
| \emph{\Large 清华大学工程物理系}\\[0.2cm] | |
| \emph{\Large \LaTeX 新手入门}\\[4.2cm] % 课程 | |
| % Title | |
| { \Large \bfseries \LaTeX 实验}\\[0.4cm] % 导引标题 | |
| { \HUGE \bfseries 新手入门}\\[0.4cm] % 主标题 | |
| { \huge \bfseries 实验报告} % 副标题 | |
| \end{flushleft} | |
| \vfill | |
| \begin{flushright} | |
| { | |
| \newcommand{\pillar}{ {\Huge \phantom{A}} } %一种统一的方法提高行高 | |
| \large \begin{tabular}{lc} | |
| \pillar {\it 姓名} & {\it DEP} \\\cline{2-2} | |
| \pillar {\it 学号} & 2011011610 \\\cline{2-2} | |
| \pillar {\it 班级} & {\it 工物00} \\\cline{2-2} | |
| \pillar {\it 报告日期} & \today \\\cline{2-2} | |
| \end{tabular} | |
| } | |
| \end{flushright} | |
| \end{titlepage} | |
| \newpage | |
| \pagenumbering{Roman} | |
| \tableofcontents | |
| \newpage | |
| \pagenumbering{arabic} | |
| \pagestyle{fancy} | |
| \fancyhead{} % 清空设置 | |
| \fancyhead[HL]{清华大学工程物理系} | |
| \fancyhead[HR]{\LaTeX 新手入门} %课程 | |
| 写在前面:本文档源代码及更多教程,请见http://pan.baidu.com/s/1o6j0HiM。 | |
| \section{实验目的} | |
| 本实验目的包括: | |
| \begin{enumerate} | |
| \item 学习高逼格的排版语言\LaTeX\. | |
| \item 给日常生活增加不必要的麻烦\. | |
| \item 大四狗要写毕业论文了,参考文献搞疯了,不用\TeX 搞不定\. | |
| \end{enumerate} | |
| \section{实验原理} | |
| 在电脑上装了ctex之后,里面有一个叫做texworks的编辑器,可以拿来写点东西。至于具体\TeX 是怎么排版的,请参阅{\it The \TeX Book}。 | |
| \section{实验仪器} | |
| 实验仪器包括一台电脑,一双灵巧的能打字的手,实验材料包括英文26个字母和中文n个字符和各种奇奇怪怪的符号和一张普通的头像: | |
| \begin{figure}[htbp] | |
| \centering | |
| \begin{subfigure}{\splitsubfigwidth} | |
| \centering | |
| %\includegraphics[width=\splitgraphicwidth]{head.jpg} | |
| \caption{一张普通的头像} | |
| \label{fig666} | |
| \end{subfigure} | |
| \hspace{\subfighspace} | |
| \begin{subfigure}{\splitsubfigwidth} | |
| \centering | |
| %\includegraphics[width=\splitgraphicwidth]{head.jpg} | |
| \caption{一张普通的头像} | |
| \label{fig888} | |
| \end{subfigure} | |
| \caption{一张普通的头像} | |
| \label{fig000} | |
| \end{figure} | |
| 图\ref{fig666}是一张普通的头像,图\ref{fig888}也是一张普通的头像,所以图\ref{fig000}是普通的头像。 | |
| \section{实验过程与数据} | |
| \subsection{缩进尝试} | |
| 这是第一段,短前有自动缩进。 | |
| \noindent | |
| 这是第二段,使用了$\backslash$noindent取消本段首行缩进, | |
| \subsection{章节尝试} | |
| 使用$\backslash$section $\backslash$subsection $\backslash$subsubsection 等分节。下面“张杰”及“小张杰”就是对section进行尝试。 | |
| \subsection{张杰} | |
| 这就是爱! | |
| \subsubsection{小张杰} | |
| 在ctex默认的section题目的字体与排布与本实验不同。因为在导言区中我使用宏包对section进行了定制。如果想要尝试不同的section风格,请自行谷歌并修改导言区。 | |
| 另外,更改字体也比较复杂,也请大家自行谷歌。 | |
| %=========================figure & table====================== | |
| \subsection{插图实验} | |
| 向文档内部插图的话,就需要用figure环境,并用graphicx宏包。 | |
| 下面是我插图的结果:(PS:在实验仪器中就插过了还用了$\backslash$subfigure这么NB的东西) | |
| \begin{figure}[htbp] | |
| \centering | |
| %\includegraphics[width=0.3\textwidth]{head.jpg} | |
| \caption{我的头像} | |
| \label{fig233} | |
| \end{figure} | |
| 在这里,figure是浮动环境,意思是图片会根据文档内容自行选择一个合适的地方。[htbp]表示在此处/页面顶部/底部/下一页插图,都不是强制性命令,latex会根据[htbp]的顺序及文档内容选择最优位置。 | |
| 接下来,我们要加标题和引用。使用的是$\backslash$caption和$\backslash$label$\&$$\backslash$ref命令。 | |
| 图\ref{fig233}是我的头像。当然$\backslash$label内部的名字可以随便起。 | |
| 这就是简单的图片插入。如果想要更花哨的效果,比如并列的图片,或者自行使用LaTeX绘图的话,需要使用一些高级宏包。请自行谷歌。 | |
| \subsection{表格插入实验} | |
| 向文章内部插入图片,推荐使用table环境。 | |
| 下面我尝试插入一个最简单的表格: | |
| \begin{table}[htbp] | |
| \centering | |
| \caption{工物一字班dota排名} | |
| \begin{tabular}{|c|c|} | |
| \hline | |
| 班级 & 名次\\ | |
| \hline | |
| 工物12 & 1\\ | |
| \hline | |
| 工物11 & 2\\ | |
| \hline | |
| 工物10 & 3\\ | |
| \hline | |
| \end{tabular} | |
| \label{tab666} | |
| \end{table} | |
| 这就是一个最基本的表格,其中table用来表示浮动,tabular才是真正的表格环境。\{ |c|c| \}表示表格内部文字按列居中,有分割线。$\backslash$hline是输入横线的命令。注意每行最后要有双斜杠换行。 | |
| 在table里面,我同样使用caption和label/ref来插入标题及引用,与图片相似,不多赘述。 | |
| 表\ref{tab666}不能说明什么。不是一一不努力,奈何一二太NB。 | |
| %=============================formula============================= | |
| \subsection{数学公式输入实验} | |
| 接下来我们要学习LaTeX最厉害之处:数学公式输入。 | |
| \LaTeX 教徒:“数学公式的标准形式就是LaTeX规定的!”(雾 | |
| 首先我在导言区加入了amsmath和amssymb宏包。这两个宏包是美国数学协会提供的标准宏包。 | |
| 我首先尝试输入牛顿定律: | |
| F=ma, $F=ma$, Newton says that F=ma, $Newton says that F=ma$ | |
| 美刀符号用来表示数学环境。可以看到最后一个公式里面文字很奇怪,因为在LaTeX中文字分为数学模式和文本模式,在数学模式中会自动斜体并忽略空格。 | |
| 应对办法是,在公式环境中使用$\backslash$quad或者$\backslash$text\{\}。 | |
| 然后我尝试了{\bf 行内公式}和{\bf 行间公式}的区别。这是能量定律(行内公式):$E=mc^2$,这也是能量定律(行间公式):\[E=mc^2\] | |
| 请对照本文档的代码看,意义自明。 | |
| 同时,我还学习了上下标的使用:$E=m_{love}c^{1+1}$ | |
| 下面是各种字母、符号、特殊公式矩阵的输入,请对照文档的代码~ | |
| 首先是希腊字母:\\ | |
| \centerline{$\alpha\beta\gamma\omega\Gamma\Omega$} | |
| 然后是奇怪的上下标:\\ | |
| \centerline{${}^2_4 He$ $\vec{E}$ $\overrightarrow{AB}$ $\dot{A}$ $\ddot{A}$ $\ddddot{A}$ $\hat{n}$ $\bar{x}$} | |
| 运算符:\\ | |
| \centerline{$+-\times\div\pm\mp\ne\le\ge=\approx$} | |
| \centerline{$\int\quad\iint\quad\iiint\oint$} | |
| 分式:\\ | |
| \centerline{$\displaystyle a=\frac{{\rm d}v}{{\rm d}t}$} | |
| 在论文中,公式需要编号: | |
| \begin{equation} | |
| E=mc^2 | |
| \end{equation} | |
| \begin{subequations} | |
| \begin{equation} | |
| E=mc^2 | |
| \label{eq2suba} | |
| \end{equation} | |
| \begin{equation} | |
| E=mc^2 | |
| \end{equation} | |
| \end{subequations} | |
| 引用式\ref{eq2suba}\\ | |
| 多行子式 | |
| \begin{eqnarray} | |
| E&=&mc^2\\ | |
| E&=&m\times c^2\\ | |
| E=&m&\times c^2 | |
| \end{eqnarray} | |
| 数组环境 | |
| \begin{equation} | |
| \left. | |
| \begin{array}{rcll} | |
| \textrm{常数}) & y & = & c\\ | |
| \textrm{直线}) & y & = & ax+b\\ | |
| \textrm{抛物线}) & y & = & ax^2+bx+c\\ | |
| \end{array} | |
| \right\} | |
| \textrm{多项式} | |
| \quad | |
| \left( | |
| \begin{array}{c|cc} | |
| a_{11} & & \\ | |
| \hline | |
| & b_{11} & b_{12} \\ | |
| & b_{21} & b_{22} | |
| \end{array} | |
| \right) | |
| \end{equation} | |
| \begin{equation} | |
| sgn(x)=\left\{ | |
| \begin{array}{lrcl} | |
| -1 & x&<&0\\ | |
| 0 &x&=&0\\ | |
| 1&x&>&0 | |
| \end{array} | |
| \right. | |
| \end{equation} | |
| 当然也可以用$\backslash$begin\{cases\}环境,自行谷歌 | |
| \begin{equation} | |
| \begin{array}{rcl} | |
| f(x) & = &(x-1)^3\\ | |
| &=&(x^2-2x+1)(x-1)\\ | |
| &=&x^3+3x^2-3x-1 | |
| \end{array} | |
| \end{equation} | |
| 当然也可以用$\backslash$begin\{split\}环境,自行谷歌 | |
| 矩阵也一样,既有专门的矩阵,也可以通过array实现。 | |
| \subsection{页面设置尝试} | |
| 新手使用$\backslash$geometry宏包,也可以使用别的,自行谷歌。 | |
| \subsection{参考文献尝试} | |
| 推荐使用$\backslash$bibtex方法,\\ | |
| 这是第\cite{gorce2000influence}篇文献,这是第\cite{deane1999air}篇文献。 | |
| bibtex使用不同的排序方式,根据$\backslash$bibliographystyle后面的参数决定。 | |
| \bibliographystyle{unsrt} | |
| \nocite{*}\bibliography{reference} | |
| \end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment