美文网首页程序员
论文神器 VSCode Latex 中文

论文神器 VSCode Latex 中文

作者: readilen | 来源:发表于2018-11-11 00:44 被阅读8次

    1.创建字体目录

    ubuntu的字体存放在 /usr/share/fonts/ 目录下

    $ sudo mkdir -p /usr/share/fonts/windows
    

    2.拷贝windows字体文件

    windows字体文件存放在C:\windows\Fonts 目录下,复制到ubuntu

    $ sudo cp ~/path/to/fonts /usr/share/fonts/winFonts/
    

    3.安装字体

    $ cd /usr/share/fonts/windows
    $ sudo mkfontscale  #(创建字体的fonts.scale文件,它用来控制字体旋转缩放)
    $ sudo mkfontdir  #(创建字体的fonts.dir文件,它用来控制字体粗斜体产生)
    $ sudo fc-cache -fv  #(建立字体缓存信息,也就是让系统认识字体)
    $ sudo fc-list :lang=zh | sort
    

    5 ubuntu安装latex

    sudo apt-get install texlive-xetex
    sudo apt-get install texlive-latex-base
    sudo apt-get install texlive-latex-extra
    sudo apt-get install texlive-fonts-recommended # 字体
    sudo apt-get install texlive-fonts-extra # 更多字体,可选
    sudo apt-get install latexmk # 要求系统已安装Perl
    

    6 安装vscode latex

    在 vscode extensions 中搜索 latex ,安装 latex workshop 扩展包
    搜索latex-workshop.latex.toolchain->右键 Replace in Setting->修改为如下代码

    "latex-workshop.latex.toolchain": [
            {
                "command": "xelatex",
                "args": [
                    "-synctex=1",
                    "-interaction=nonstopmode",
                    "-file-line-error",
                    "%DOC%"
                ]
            }, {
                "command": "bibtex",
                "args": [
                    "%DOCFILE%"
                ]
            }, {
                "command": "xelatex",
                "args": [
                    "-synctex=1",
                    "-interaction=nonstopmode",
                    "-file-line-error",
                    "%DOC%"
                ]
            }, {
                "command": "xelatex",
                "args": [
                    "-synctex=1",
                    "-interaction=nonstopmode",
                    "-file-line-error",
                    "%DOC%"
                ]
            }
        ]
    

    7 Example

    %!TEX program = xelatex
    \documentclass{article}
    \usepackage[a4paper, left=1in, right=1in, top=1in, bottom=1in]{geometry}
    \usepackage{xeCJK} %调用 xeCJK 宏包
    
    \begin{document}
    
    \tableofcontents
    
    \begin{abstract}
    这是在文件的开头的介绍文字.本文的主要话题的简短说明.
    \end{abstract}
    
    \section{ 前言 }
    在该第一部分中的一些额外的元素可以被添加。巴贝尔包将采取的翻译服务.
    
    \section{关于数学部分}
    在本节中的一些数学会使用数学模型含中文字符显示。
    这是一个非常棒的体验
    我太爱
    \end{document}
    

    在我们编写 LaTeX 文档的时候,有两个命令很特殊,一个是 %!TEX program = xelatex,一个是 % !TEX root = relative/or/absolute/path/to/root/file.tex,前者指定编译方式,后者指定主(根)文件,借助这个,我们可以对不同文档设定不同的编译方式,这就简化了编译时的麻烦。


    相关文章

      网友评论

        本文标题:论文神器 VSCode Latex 中文

        本文链接:https://www.haomeiwen.com/subject/mdotfqtx.html