网站域名如何查询,上海室内设计公司哪家好,怎么建设网站数据库,app软件开发平台有哪些LaTeX使用 LaTeX使用基本使用源文件的基本结构中文处理办法字体字号设置文章基本结构特殊字符处理图片的使用表格的使用Texstduio的导入表格功能会更快浮动体的使用数学公式初步矩阵的使用TexStudio里面的矩阵模板功能参考文献使用BibTex定义自己的命令 基本使用
sublime使用…LaTeX使用 LaTeX使用基本使用源文件的基本结构中文处理办法字体字号设置文章基本结构特殊字符处理图片的使用表格的使用Texstduio的导入表格功能会更快浮动体的使用数学公式初步矩阵的使用TexStudio里面的矩阵模板功能参考文献使用BibTex定义自己的命令 基本使用
sublime使用latex格式来编辑文件使用commandB来编译文件这时候通过skim来浏览生成的PDF文件。终端里面通过使用latex demo.tex来编译latex生成包括demo.dvi在内的许多文件这个时候用dvipdfmk demo.dvi命令转成PDF。终端里面通过使用xelatex demo.tex直接生成PDF文件。还支持中文 支持中文需要xelatex,utf-8编码导入ctex包使用TexStudio来使用Latex
源文件的基本结构
Latex里面有文稿区正文区Latex里面不用显示的内容默认用注释而不是删除\后面跟的都是关键字一个$包围表示行内数学公式两个$包围表示行间数学公式文档类里面有book,report,letter,ctexreport,ctexbook等文档类
%导言区
\documentclass{article} %book,report,letter
\usepackage{ctex}
\title{Latex Introduction}
\author{Shu Kai}
\date{\today}
%文稿区
\begin{document}\maketitle你好 \LaTeX.Here is a formula$f(x)x^22x1$Here is an another formula$$f(x)2x$$which $x$ denote independent variable.
\end{document}
中文处理办法
命令行中使用texdoc ctex可以查看ctex的使用方法或者使用texdoc lshort-zh来查看latex的简短的中文介绍。使用\heiti,\kaishu来选择不同的字体使用eqution来产生具有序号的数学公式使用\newcommand\yourcmd{xxxcmd}来定义自己的command使用ctex开头的文档类可以不用引入ctex包
%导言区
\documentclass{ctexart} %book,report,letter
%\usepackage{ctex} %or use \documentclass{ctexart}
\title{Latex Introduction}
\newcommand\degree{^\circ}
\author{\heiti 舒凯}
\date{\today}
%文稿区
\begin{document}\maketitle你好 \LaTeX.$C90\degree$\begin{equation}ABBCCA\end{equation}
\end{document}
字体字号设置
下图是Latex的字体属性 * 字体族对于latex中的字体可以使用不同的字体族比如说有罗马字体san serif字体(无衬线字体),typerwriter字体。 * 对于字体的使用可以用命令或者用定义。对于命令有一个括号作为限定范围对于定义可以有括号也可以没有括号没有括号表示接下去的内容全部是该字体。 * 我们可以在引言区用newcommand设置自己的字体。
\documentclass{article}
\usepackage{ctex}
\newcommand{\myfont}{\textbf{\textsf{ss}}}
\begin{document}%字体族设计 罗马字体 无衬线字体 打印机字体\textrm{Roman Family} \textsf{Sans Serif Family} \texttt{TypeWriter Family}%以下的命令表示后续字体的字体族\rmfamily{Roman Family} \sffamily{Sans Serif Family} \ttfamily{TypeWriter Family}%字体系列设置(粗细宽度)\textmd{Medium Series} \textbf{BoldFace Series}%字体形状(直立斜体伪斜体小型大写)\textup{Upright Shape} \textit{Italic Shape}\textsl{Slanted Shape} \textsc{Small Caps Shape}%中文字体{\songti 宋体} {\heiti 黑体} {\fangsong 仿宋} {\kaishu 楷书}%字体大小设置{\tiny Hello}\\{\scriptsize Hello}\\ {\footnotesize Hello}\\{\small Hello}\\{\normalsize Hello}\\{\large Hello}\\{\Large Hello}\\{\LARGE Hello}\\{\huge Hello}\\{\Huge Hello}\\%中文字号设置\zihao{5} 你好\myfont\end{document}
文章基本结构
对于article类的文档来说里面有section,subsection,subsubsection等等命令。对于book类的文档来说有chaptersection等此时subsection和subsubsection等等命令就不能发挥作用。可以在文档区也就是正文区的前面使用tableofcontents这个命令利用好引言区尽量在引言区里面设置好格式。
\documentclass{book}
\usepackage{ctex}
\begin{document}\tableofcontents\section{引言}\section{摘要}\section{实验}\subsection{实验}\subsubsection{图表}\chapter{章节}\section{引言}\section{摘要}\section{实验}\subsection{实验}\subsubsection{图表}
\end{document}
特殊字符处理
\documentclass{book}
\usepackage{ctex}
\usepackage{xltxtra}
\usepackage{texnames}
\usepackage{mflogo}
\begin{document}\section{空白字符}%空行分段多个空行等于一个空行%自动缩进绝对不能使用空格代替%英文中多个空格为一个空格中文中空格无效%汉字与其它字符的间距会自动由XeLeTex自动处理%禁止使用中文全角空格Are you OK!我爱 你Do you love me !滚%1em(相当于字体中M的宽度)a\quad b%2ema\qquad b%约为1/6个ema\,b a\thinspace b%0.5ema\enspace b%空格a\ b%硬空格 不能分割的空格a~b%1pc12pt4.218mma\kern 1pc ba\kern -1em ba\hskip 1em b%根据参数留出空白a\hspace{35pt}b%根据xyz的宽度得到占位宽度的空白a\hphantom{xyz}b%弹性宽度a\hfill b\section{\LaTeX 控制符}%双反斜杠表示换行所以要显示反斜杠需要用\textbackslash\# \$ \% \{ \} \~{} \_{} \^{} \textbackslash \\section{排版符}\S \P \dag \ddag \copyright \pounds\section{\TeX 标志符号}%基本符号\TeX \LaTeX \LaTeXe%XeLaTex符号,使用xltxtra宏包\XeLaTeX%texnames宏包提供\AmSTeX{} \AmS-\LaTeX{}\BibTeX{} \LuaTeX{}%由mflogo提供\METAFONT{} \MF{} \MP{}\section{引号} 你好\section{连字符}- -- ---\section{非英文字符}\oe \OE \ae \AE \aa \AA \o \O \l \L \ss \SS ! ?\section{重音符号}\o \o \^o \ o \~o \o \.o \u{o} \v{o} \H{o} \r{o} \t{o} \b{o}\c{o} \d{o}\section{实验}\subsubsection{图表}
\end{document}
效果输出:
图片的使用
需要在导言区里面导入graphicx这个包插入图片的时候使用以下命令,\includegraphics[选项]{文件名}支持以下格式的图片 EPS,PDF,PNG,JPEG,BMP在导入图片的时候可以不用加后缀名。选项有scale,width,height,angle等选项而且支持相对值
\documentclass{article}
\usepackage{ctex}
%导言区 \usepackage{graphicx}
%语法 \includegraphics[选项]{文件名}
%格式 EPS,PDF,PNG,JPEG,BMP
\usepackage{graphicx}
\graphicspath{{figures/},{pics/}} %图片在当前目录下的figures目录%正文区(文稿区)
\begin{document}\LaTeX{} 中的插图\includegraphics{1.png}\includegraphics{2.png}\includegraphics{3.png}\includegraphics[scale0.3]{1.png}\includegraphics[scale0.5]{2.png}\includegraphics[scale0.8]{3.png}\includegraphics[width1cm]{1.png}\includegraphics[width2cm]{2.png}\includegraphics[width3cm]{3.png}\includegraphics[height1cm]{1.png}\includegraphics[height2cm]{2.png}\includegraphics[height3cm]{3.png}\includegraphics[width0.1\textwidth]{1.png}\includegraphics[width0.2\textwidth]{2.png}\includegraphics[width0.3\textwidth]{3.png}\includegraphics[height0.1\textheight]{1.png}\includegraphics[height0.2\textheight]{2.png}\includegraphics[height0.3\textheight]{3.png}\includegraphics[angle-45,width0.2\textwidth]{1.png}\includegraphics[width0.2\textwidth]{2.png}\includegraphics[angle45,width0.2\textwidth]{3.png}
\end{document}
表格的使用(Texstduio的导入表格功能会更快)
在begin和end里面使用tabular可以创建表格l,c,r 左中右;p指示宽度不够就换行\\表示换行\hline表示行线可以有多个叠加|是竖线可以有多个叠加
\documentclass{article}
\usepackage{ctex}%正文区(文稿区)
\begin{document}\LaTeX{} 中的表格\begin{tabular}{l|c|c|p{1.5cm}|r} %l,c,r 左中右;p指示宽度不够就换行\hline %使用两个\hline表示双横线姓名 语文 数学 英语 备注 \\ % \\表示换行\hline 张三 90 86 93 优秀 \\\hline李四 60 70 80 良\\\hline王五 50 80 66 差 \\\hline\end{tabular}\end{document}
浮动体的使用
浮动体可以实现灵活分页,比如figuretable(避免无法分割的内容产生的页面的空白)给图表添加标题交叉引用允许位置的参数h(here)表示此处代码所在的上下文位置;t(top)代码所在页面或之后页面的顶部;b(bottom)代码所在页面或之后页面的底部;p(page)独立页面——浮动页面标题控制caption,bicaption等宏包并排与子图表 subcaption,subfig,floatrow等宏包绕排 picinpar,wrapfig等宏包
\documentclass{article}
\usepackage{ctex}
\usepackage{graphicx}
\graphicspath{{figures/}}
%正文区(文稿区)
\begin{document}\LaTeX{} 中的图片如图\ref{天线} 所示%交叉引用\begin{figure}[htbp] %允许位置\centering\includegraphics[scale0.3]{1}\caption{天线衰减图}\label{天线}\end{figure}以下是2014年我们班的成绩如表格\ref{grade}所示\begin{table}[h]\centering\caption{成绩单}\label{grade}\begin{tabular}{l|c|c|p{1.5cm}|r} %l,c,r 左中右;p指示宽度不够就换行\hline %使用两个\hline表示双横线姓名 语文 数学 英语 备注 \\ % \\表示换行\hline 张三 90 86 93 优秀 \\\hline李四 60 70 80 良\\\hline王五 50 80 66 差 \\\hline\end{tabular}\end{table}
\end{document}
数学公式初步
行内数学用,行间用,行间用$希腊字母用相应的发音注意交叉引用\frac{}{}用来表示分式
\documentclass{article}
\usepackage{ctex}
\usepackage{graphicx}
\graphicspath{{figures/}}
%正文区(文稿区)
\begin{document}
\section{行内公式}
\subsection{美元符号}
交换公式是$abba$所示
\subsection{小括号}
交换公式是\(abba\)所示
\subsection{math环境}
交换公式是\begin{math}abba\end{math}所示
\section{上标}
$a^2$
\section{下标}
$a_2$
\section{希腊字母}
$\alpha$
$\beta$
$\gamma$
$\epsilon$
$\pi$
$\omega$$\Gamma$
$\Delta$
$\Theta$
$\Pi$
$\Omega$
\section{数学函数}
$\log$
$\sin$
$\cos$
$\arcsin$
$\arccos$
$\ln$$\sin^2 x\cos^2 x1$$y\sin^{-1} x$$y\sqrt{2}$$y\sqrt[4]{5x}$
\section{分式}
体积大约是原来的$3/4$
体积大约是原来的$\frac{5}{100}$
\section{行间公式}
\subsection{美元符号}
交换律是
$$abba$$
如
$$12213$$
\subsection{中括号}
\[abba\]
如
\[12213\]
\subsection{displaymath环境}
\begin{displaymath}12213
\end{displaymath}
\subsection{自动编号公式equation环境}
交换律见式\ref{eq:commutative}
\begin{equation}abba \label{eq:commutative}
\end{equation}
公式的编号与交叉引用是自动实现的大家在排版中要习惯采用自动化的方式处理诸如图表公式的编号与交叉引用。
\end{document}
矩阵的使用(TexStudio里面的矩阵模板功能)
参考文献(使用BibTex) 一次管理一次使用thebibliography环境(不推荐),推荐使用BibTex文件把文献单独管理方便后续使用 \documentclass{article}
\usepackage{ctex}%正文区(文稿区)
\begin{document}
%一次管理,一次使用
%参考文献格式
%\begin{thebibliography}{widestlabel}
% \bibitem[记号]{引用标志}文献条目1
% \bibitem[记号]{引用标志}文献条目2
% ...
%\end{thebibliography}
%其中文献条目包括作者题目出版社年代版本页码等
%引用文章的使用采用: \cite{引用标志1引用标志2}
\end{document}
自己编辑一个bib文件然后进行引用或者用google学术搜索然后点击引用的按钮选择BibLatex的格式
下面是一个Bib文件
BOOK{mittebach2004,
title{The {{\LaTeX}} Companion},
publisher {Addison-Wesley},
year{2004},
author{Frank Mittelbach and Michel Goossens},
series{Tools and Techniques for Computer Typesetting},
address{Boston},
edition{Second}
}
article{comaniciu2003kernel,title{Kernel-based object tracking},author{Comaniciu, Dorin and Ramesh, Visvanathan and Meer, Peter},journal{IEEE Transactions on pattern analysis and machine intelligence},volume{25},number{5},pages{564--577},year{2003},publisher{IEEE}
}
然后引入该文件并在相应的地方进行引用
\documentclass{article}
\usepackage{ctex}
\bibliographystyle{plain} %plain unsrt alpha abbrv
%正文区(文稿区)
\begin{document}
%一次管理,一次使用
%参考文献格式
%\begin{thebibliography}{widestlabel}
% \bibitem[记号]{引用标志}文献条目1
% \bibitem[记号]{引用标志}文献条目2
% ...
%\end{thebibliography}
%其中文献条目包括作者题目出版社年代版本页码等
%引用文章的使用采用: \cite{引用标志1引用标志2}
\bibliography{literacy}
\cite{mittebach2004}
\cite{comaniciu2003kernel}
\end{document}
定义自己的命令
使用newcommand命令来定义自己的命令可以在方括号里面设置默认参数然后默认参数在花括号里面放在第一个
\documentclass{article}
\usepackage{ctex}
\newcommand\PRC{Public of \emph{China}}
%最多有9个#的参数
\newcommand\loves[2]{#1 喜欢 #2}
\newcommand\hatedby[2]{#1 不受 #2 喜欢}
%默认参数,放第一个位置
\newcommand\love[3][喜欢]{#2#1#3}
%正文区(文稿区)
\begin{document}
\PRC\loves{猫}{鱼}\hatedby{狗}{猫}\love{猪}{喜欢}{狗}
\end{document}