zoukankan      html  css  js  c++  java
  • LaTex 2

    LaTex 入门

    此时是否安装成功

    • 如果安装成功了LaTeX, 那么在计算机上会多出来LaTeX的编译器, LaTex Live 安装包在计算机上安装了多个不同的编译器, 有latex, xelatex, pdflatex等等
    • latex -v 或者 xelatex -v测试是否安装成功

    升级软件

    • tlmgr update --all 其中tlmgr是Tex Live Manager, 因为墙的原因, 升级的过程可能会比较长

    第一个Hello, World

    使用latex编译器编译

    • vim test.tex
    
    documentclass{article}
    author{JH}
    	itle{Demo}
    
    egin{document}
    
    Hello, World!
    
    end{document}
    
    • latex test.tex # 对test.tex进行编译, 生成.aux, .log 和 .dvi
    • dvipdfmx test.dvi # 将.dvi转为.pdf

    使用xelatex编译器编译

    • vim test.tex
    
    documentclass{article}
    author{JH}
    	itle{Demo}
    
    egin{document}
    
    Hello, World!
    
    end{document}
    
    • xelatex test.tex # 直接生成pdf
    • 如果要支持中文, 需要将文件保存为UTF-8编码格式并且使用ctex宏包, usepackage{ctex}

    .tex文件格式

    • 格式
    
    % 导言区
    % 在导言区定义文档的属性
    documentclass[12pt]{aritcal} % report, book, letter, 其中12pt控制的是正文的大小
    
    author{JH} % 可以修改字符, 使用author{kaishu JH}, 但是前提是导入了ctex宏包, 宏包就是类似于C语言中的#include, 将ctex中定义的属性拷贝到当前文件中
    	itle{This is My First Document}
    date{	oday}
    % 在导言区可以
    ewcommand定义新的命令
    
    ewcommand
    ame{content}
    
    % 正文区
    egin{document}
    maketitle % 在导言区定义的属性生效, 注意在文档格式为letter中没有maketitle命令
    % 在这里写正文
    % 正文包含两个模式, 一个是文本模式, 另一个是数学模式
    end{document}
    

    写文件

    • 应该先写出大纲, 在使用 ableofcontents命令生成目录
    • 示例
    
    documentclass{article}
    
    author{JH}
    	itle{JH}
    
    
    ewcommandsuper{jh}
    
    egin{document}
    maketitle
    
    	ableofcontents
    section{section1}
    subsection{subsection1}
        hello, subsection1!
    subsection{subsection2}
        hello, subsection2!
    section{section2}
    subsection{subsection3}
        hello, subsection3!
    subsection{subsection4}
        hello, subsection4!
    section{section3}
    subsection{subsection5}
        hello, subsection5!
    subsection{subsection6}
        hello, subsection6!
    
    end{document}
    
    • 空行分段, 多个空行为1个
    • 自动缩进, 不要使用空格缩进

    数学公式

    • 使用$$和$$ $$插入没有标号的公式
    • 使用egin{equation} formula end{equation}插入有标号的公式

    插入图片

    • usepackage{graphicx} % 导入宏包
    • graphicspath{{figures/}, {pictures/}} % 这是图片查找路径, 这个很必要
    • includegraphics[scale=0.3]{path} % 插入图片

    插入表格

    
    egin{tabular}{l|c|c|r} % l左对齐, r右对齐, c居中对齐
    hline % 竖线
    name & age & score \
    foo & 18 & 100 \
    bar & 22 &  96 \
    end{tabular}
    

    浮动体

    • 为了更好的排版表格和图片分别使用
    
    egin{table}
            caption{Table} % 标题
            \
            centering % 居中
            egin{tabular}{|l|c|c|r|}
                hline
                name & age & score \
                hline
                foo & 18 & 100 \
                hline
                bar & 22 & 98 \
                hline
            end{tabular}
        end{table}
        
    egin{figure}[htbp] % 建议加上htbp
    
    includegraphics[scale=0.3]{path}
    end{figure}
    

    CTeX

    • section左对齐: CTEXsetup[format={Largefseries}]{section}

    案例

    
    documentclass[12pt]{ctexart}
    usepackage{graphicx}
    % usepackage{ctex}
    
    graphicspath{{wallpapers/}}
    
    	itle{论文}
    author{某人}
    date{	oday}
    
    CTEXsetup[format={Largefseries}]{section}
    
    egin{document}
    	maketitle
    		ableofcontents
    	section{介绍}
    	我就是我,是颜色不一样的烟火。
    	subsection{背景}
    	subsection{调查}
    	section{我们的工作}
    	subsection{构建模型}
    	subsection{选择参数}
    	section{分析}
    	subsection{灵敏性分析}
    	section{总结}
    	subsection{优点}
    	subsection{缺点}
    	
    	egin{equation}
    		J(	heta)=sum_{i=1}^{m}(h(x^{(i)})-y^{(i)})^{2}
    	end{equation}
    	
    	is the basic function.
    	
    	    
    	egin{figure}[htbp]
    		includegraphics[scale=0.1]{1}
    		centering
    		caption{伦敦的公交车} label{fig-bus}
    	end{figure}
    	
    	
    end{document}
    

    注意

    • LaTeX中一个或者多个空白行表示一个 , 使用强制换行
  • 相关阅读:
    使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错。字符串的长度超过了为 maxJsonLength 属性设置的值。
    PowerDesigner 连接数据库,更新数据库;
    Spark Worker启动Driver和Executor工作流程
    获取spark-submit --files的文件内容
    JVM虚拟机选项:Xms Xmx PermSize MaxPermSize区别(转)
    在Java应用中通过SparkLauncher启动Spark任务
    通过thriftserver的beeline/jdbc等方式连接到SparkSQL
    Spark:java.net.BindException: Address already in use: Service 'SparkUI' failed after 16 retries!
    Spark Sql之ThriftServer和Beeline的使用
    Spark SQL读取Oracle的number类型的数据时精度丢失问题
  • 原文地址:https://www.cnblogs.com/megachen/p/10003972.html
Copyright © 2011-2022 走看看