这个例子虽小,但是写文章最常用的功能都已经涵盖其中,适合入门学习或是作为脚手架使用。
以下是这个例子的latex代码:
\documentclass[UTF8,a4paper]{ctexart} \usepackage{xcolor} \usepackage{verbatim} \usepackage{graphicx} \usepackage{amsmath} \usepackage{listings} \lstset{ backgroundcolor=\color{yellow!10}, frame=single } \usepackage{hyperref} \hypersetup{ colorlinks=true, urlcolor= magenta, linkcolor=black, anchorcolor=black, citecolor= black, menucolor = black } \bibliographystyle{unsrt} %参考文献样式 \setcounter{tocdepth}{1} %目录深度 \title{一个LaTeX例子} \author{张子凡} \date{\today} \begin{document} \maketitle \tableofcontents \newpage \section{层次} \LaTeX 提供了7个\footnote{article或ctexart文档类section是最高层}层次,可以用他们来组织目录的层次 \begin{lstlisting} \part{...} %Level -1 \chapter{...} %Level 0 \section{...} %Level 1 \subsection{...} %Level 2 \subsubsection{...} %Level 3 \paragraph{...} %Level 4 \subparagraph{...} %Level 5 \end{lstlisting} \section{列表} \noindent 无序列表 \begin{itemize} \item c++ \item PHP \item JS \end{itemize} 有序列表 \begin{enumerate} \item c++ \item PHP \item JS \end{enumerate} \section{交叉引用} 在 \LaTeX 中我们可以任意设置标签\label{sec:marker}, 然后引用标签前面最近一个对象(章、节、图、表等)的编号或者页码,这就是交叉引用(cross reference)。 交叉引用实例:如图\ref{fig:myphoto3}、第\ref{sec:marker}节、\hyperref[fig:myphoto3]{插入pdf图片} \section{超链接} \url{https://fivecakes.com}、\href{https://fivecakes.com}{五块蛋糕} \section{插入图片} 插入图片时一般使用\verb|\begin{figure}[htbp]...\end{figure}|环境包裹,因为figure环境可以支持浮动,这使分页更加美观。 \begin{figure}[htbp] \centering \includegraphics[width=\textwidth]{rocket.jpeg} \caption{插入jpeg格式图片} \label{fig:myphoto1} \end{figure} \LaTeX 不支持插入svg格式图片,需要将svg转换成pdf格式插入。 \begin{figure}[htbp] \centering \includegraphics[width=\textwidth]{元素周期表.pdf} \caption{插入pdf格式图片} \label{fig:myphoto3} \end{figure} \section{数学公式} $$ \begin{aligned} \frac{\partial}{\partial\theta_j}J(\theta) &= \frac{\partial}{\partial\theta_j}\frac{1}{2}(h_\theta(x) - y)^2 \\ &= 2\frac{1}{2}(h_\theta(x) - y)\frac{\partial}{\partial\theta_j}(h_\theta(x) - y) \\ &= (h_\theta(x) - y)\frac{\partial}{\partial\theta_j}(\sum_{i=1}^n \theta_ix_i - y) \\ &= (h_\theta(x) - y)x_j \end{aligned} $$ \section{表格} $$ \begin{array} {|c|c|c|} \hline \color{black}{\text{black}} & \color{red}{\text{red}} & \color{yellow}{\text{yellow}} \\ \hline \color{blue}{\text{blue}} & \color{green}{\text{green}} & \color{purple}{\text{purple}} \\ \hline \color{olive}{\text{olive}} & \color{teal}{\text{teal}} & \color{lime}{\text{lime}} \\ \hline \end{array} $$ \nocite{*} \bibliography{latex_note.bib} \end{document}
以下是latex_note.bib文件的内容
@BOOK{leitaihe, title = {雷太赫排版系统简介.pdf}, author = {包太雷} } @BOOK{latex2e, title = {LaTeX2e插图指南.pdf}, author = {Keith Reckdahl} } @BOOK{latexrumen, title = {LaTeX入门.pdf}, author = {刘海洋} }
你的大名*
电子邮箱*