数学建模MCM/ICM——LaTeX排版

来源:互联网 发布:淘宝买刀剑会被扣留不 编辑:程序博客网 时间:2024/05/20 01:08

LATEX简介

一种基于TEX的排版系统,优点如下:

  • 数学公式美观
  • 便于处理复杂表格
  • 生成的PDF文件质量高,这是相对于Word转PDF而言,不存在那些细节问题
  • (至少本人看来)用于论文排版在效率和美观上都优于Word,简单入门后即可解决大多数常见问题
  • 语法简单易懂
  • 跨平台

LATEX资源

  • CTEX下载地址http://www.ctex.org/HomePage
  • 在线编译https://cloud.sagemath.com/projects
  • 初步入门资料http://math.ecnu.edu.cn/~latex/(这套PPT讲的很不错,比一些常见的书籍好多了,看完基本就算入门了)
  • 各种利用LATEX制作的图http://www.pgfplots.net/tikz/examples/
  • 在线文档http://www.ctex.org/documents/packages/layout/index.htm
  • 中文社区http://www.latexstudio.net/(还算活跃,有问题可以在这里寻求帮助)
  • 一个问答论坛,基本上较难的问题最后都可以在这里解决http://tex.stackexchange.com/questions
  • 在线公式编辑器,生成相应的LATEX公式代码(MathType也有此功能)http://tex.stackexchange.com/questions
  • 将表格转为LATEX代码(一个Excel宏:Excel2LaTeX)https://www.ctan.org/tex-archive/support/excel2latex/

简单入门

注意事项

  • 这里有我自己做的CUMCM模板,注释详尽https://github.com/Momingcoder/LaTeX-for-CUMCM
  • 编辑器WinEdt,使用PDFTeXify较好,插入图片时选择PDF格式,要注意图片不要太大,否则最后生成的PDF也会很大
  • 想随时预览的可以安装TeXstudio http://www.texstudio.org/
  • 对于Matlab绘图导出时中文乱码的问题:对图进行打印,选择Microsoft PDF打印即可,裁剪时可直接用PS,效果拔群。
  • Gsview裁剪eps文件(Ctex已内置该软件):菜单栏“options–show bounding boxs”选中,打开eps图,然后File->PS TO EPS,不选择Automatically calculate Bounding Box,然后点击yes,用鼠标单击左、下、右、上边进行裁剪即可,输出为eps(需要自己加后缀)
  • MathTypeExcel2LaTeX很方便,尽量学会使用

编译命令

  • 编译出错时,屏幕上有问号,等待用户输入命令:
    Enter:继续处理
    X:退出
    ?:显示可以使用的命令
    S:忽略后续错误
    R:执行下去,出现错误也不停留
    Q:不提示任何消息地执行
    I:插入一些内容
    E:编辑源文件
    H:显示帮助

基本语法

其实和HTML有些类似,当然要比HTML和Markdown复杂。

  • Hello World
  • begin{xxx}和end{xxx}构成一个环境,一篇文章只能有一个document环境
\documentclass[11pt]{article}\begin{document}Hi. This is my first \LaTeX file.\end{document}
  • 使用宏包
\usepackage{ctex}\usepackage[margin=2.5cm]{geometry} %页面设置
  • 自定义命令
% \newcommand{\yourcommand}[参数个数]{内容}\newcommand{\hei}{\CJKfamily{hei}}\newcommand{\song}{\CJKfamily{song}}
  • 居中
\centerline{…}  %单行\begin{center}%多行\end{center}\centering  %表格
  • 分行
\linebreak[n]   %建议分行,n可取0,1,2,3,4,数字越大建议力度越大\linebreak      %强制换行,撑满整行,增加字间距\nolinebreak    %建议不分行,用法同\linebreak,作用于单个字\mbox{文本内容} %使文本内容保持在同一行\CJKkern        %禁止在所在的两汉字间换行
  • 分页
\newpage            %强制分页\pagebreak[n]       %建议分页\nopagebreak[n]%增加当前页高度从而避免难看的分页:\enlargethispage{尺寸} %可增加的最大高度\enlargethispage*{尺寸} %严格指定增加高度
  • 间距
%水平间距\quad           %插入空白,相当于当前字体尺寸大小\qquad          %相当于两倍的\quad\               %大约为\quad的3/18\hspace{宽度大小}   %\hspace*{宽度大小}\hfill          %弹性长度,根据排版需要插入空白\hspace{\fill}  %撑满整行\hphantom{文本}   %占据文本的宽度\setlength{\parskip}{2em}   %段落间距
  • 首行缩进
\CJKindent  %首行缩进2汉字\setlength{\parindent}{2em}\indent\noindent
  • 字体
\upshape    %直立字体\slshape    %斜体\mdseries   %中等权重\bfseries   %粗体%GBK中包含的中文字体有以下几种\song   %宋\kai    %楷\fs     %仿宋\hei    %黑体\li     %隶书\you    %幼圆\textstyle          %正文样式\scriptstyle        %角标样式\scriptscriptstyle  %二级角标样式
  • 公式
$...$   %行内公式\begin{equation}\label{}%标签 …… %行间公式\end{equation}\ref{label}     %引用%阵列\begin{array}{ccc}%三行三列,每列元素居中为c,居左为l,居右为r   &  &  \\   &  &  \\   &  &  \end{array}%矩阵\left(  \begin{array}{ccc}     &  &  \\     &  &  \\     &  &  \\  \end{array}\right)%公式按照章节编号\makeatletter % `@' now normal "letter"\@addtoreset{equation}{section}\makeatother  % `@' is restored as "non-letter"\renewcommand\theequation{\arabic{section}.{\arabic{equation}}}
  • 表格
\begin{table}  \centering    %居中  *  \caption{}\label{}    %标题、标签\end{table}
\begin{figure}  \centering  % Requires \usepackage{graphicx}  \includegraphics[width=]{}\\    %宽度(会自动锁定纵横比)、路径  \caption{}\label{}    %标题、标签\end{figure}
  • 章节
%可以简单认为是一级、二级、三级、小节、小小节\section{}\subsection{} \subsubsection{} \paragraph{}\subparagraph{} 
  • 标题中文化
\renewcommand{\partname}{}\renewcommand{\thepart}{}\renewcommand{\chaptername}{}
  • 设置标题
\titleformat{\section}{\CJKfamily{hei}\sihao\centering}{\thesection}{1em}{} %设置章节标题字体为黑体\titlespacing{\section}{0pt}{2.5\wordsep}{2\wordsep}    %设置章节标题间距\titleformat{\subsection}{\CJKfamily{hei}\xiaosi}{\thesubsection}{0.7em}{}  %设置二级标题\titlespacing{\subsection}{0pt}{1.5\wordsep}{1\wordsep} %设置章节标题间距\titleformat{\subsubsection}{\CJKfamily{song}\xiaosi}{\thesubsubsection}{0.4em}{}   %设置三级标题\titlespacing{\subsubsection}{0pt}{0.5\wordsep}{0.5\wordsep}    %设置章节标题间距
  • 插入其他tex文件
\input{}
  • 页眉页脚
\pagestyle{版式}      %有如下几种版式%plain:页眉为空,页码居中(缺省)%empty:页眉页脚都为空,不显示页码%headings:显示页眉(页码、页眉标题)
  • 参考文献
\begin{thebibliography}{2}\bibitem{cite1}***\bibitem{cite2}***\end{thebibliography}
  • 附录
\begin{appendices}\section{Main}\lstinputlisting{./code/Main.m}\section{DrawArea}\lstinputlisting{./code/DrawArea.m}\end{appendices}
  • 复杂表格
\usepackage{multirow} \multirow{nrows}[bigstructs]{width}[fixup]{text}%nrows  设定所占用的行数。%bigstructs 此为可选项,主要是在你使用了 bigstruct 宏包时使用。%width  设定该栏文本的宽度。如果想让 LaTeX 自行决定文本的宽度,则用 * 即可。%fixup  此为可选项,主要用来调整文本的垂直位置。%text   所要排版的文本。可用 \\ 来强迫换行。\par\vspace{-1.2em}%调整与前文的距离\begin{table}[htbp]  \caption{\label{table:SNN}SNN参数测试表}  \centering  %\setlength{\abovetopsep}{1mm}%表名与表之间距离  \setlength{\belowbottomsep}{-0.8em}%表尾与后文之间距离  \tabcolsep0.15in%设置列间距  \begin{tabular}{ccccccc}  \toprule  \multirow{2}{*}{参数} & t=12 & t=15 & t=18 & t=21 & t=24 & t=27 \\                  & n(\%) & n(\%) & n(\%) & n(\%) & n(\%) & n(\%)\\  \midrule  k=20 & 0(0.0) & 9(7.4) & 83(68.0) & / & /& / \\  k=25 & 0(0.0) & 0(0.0) & 2(1.6) & 31(25.4) & 110(90.2) & / \\  k=30 & 0(0.0) & 0(0.0) & 0(0.0) & 0(0.0) & 11(9.0) & 55(45.1) \\  \bottomrule  \end{tabular}\end{table}\par%列宽控制:\begin{tabular}{|p{0.6cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|}  \hline  % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...  评阅人 & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\  \hline  评分 & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\  \hline  备注 & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\  \hline\end{tabular}
  • 多图插入
\usepackage{subfig}%多图\begin{figure}  \centering  \subfloat[]{   (可添加子图名称) \label{}    \begin{minipage}[t]{0.5\linewidth}    \centering    \includegraphics[width=4in]{./figure/pic1.eps}    \end{minipage}    }  \subfloat[]{    \begin{minipage}[t]{0.5\linewidth}    \centering    \includegraphics[width=4in]{./figure/pic2.eps}    \end{minipage}    }    \vspace{-1em}  \caption{初始图和结果图}\label{fig:lunmu}\end{figure}
1 0
原创粉丝点击