zoukankan      html  css  js  c++  java
  • Ubuntu LaTeX 中文环境配置 与 VSCode LaTeX Workshop

    1. Ubuntu LaTeX 环境配置

    安装 TeXLive
    这里直接安装 texlive-full完全体,避免后续缺少依赖。安装包较大,需要等待一段时间。
    主要使用TeXLive中的XeLaTeX,XeLaTeX已经集成了中文环境。

    sudo apt-get install texlive-full
    

    安装 cjk 宏包

    sudo apt-cache search cjk
    

    添加字体
    这里我以添加宋体为例:
    从Windows下 C:WindowsFonts 目录中拷贝 simsun.ttc,或从互联网上下载宋体字体。
    Ubuntu下进入 /usr/share/fonts/ 文件夹,为了避免与Ubuntu系统自带字体冲突,新建文件夹 winfonts

    cd /usr/share/fonts/
    sudo mkdir winfonts
    

    将准备好的 simsun.ttc 文件移动至 winfonts 文件夹下,并刷新字体库

    sudo mkfontscale
    sudo mkfontdir
    sudo fc-cache
    

    字体添加完毕后,可以通过 fc-list :lang=zh 查看中文字体的安装情况,如下

    $ fc-list :lang=zh
    ... // 省略一些输出
    /usr/share/fonts/winfonts/simsun.ttc: SimSun,宋体:style=Regular,常规 // 表示宋体已经加载完成,字体名为 SimSun
    ... // 省略一些输出
    

    测试中文LaTeX环境
    新建文件 test.tex,并输入测试样例。

    documentclass{article}
    usepackage[a4paper, left=1in, right=1in, top=1in, bottom=1in]{geometry}
    usepackage{xeCJK}
    usepackage{listings}
    author{xqmeng}
    date{2020.11.05}
    setmainfont{SimSun}
    	itle{LaTeX 中文测试}
    egin{document}
    maketitle
    egin{center}
    end{center}
    section{段落}
    你好,世界。
    Hello world.
    end{document}
    

    使用 XeLaTex 编译 test.tex

    xelatex test.tex
    

    顺利的话可以看到生成了 test.pdf。

    2. VSCode LaTeX Workshop

    VSCode 商店中搜索 LaTeX workshop,并安装

    修改 setting.json

    F1,搜索 Open Settings,进入 setting.json

    settings.json中添加以下关于 LaTeX Workshop 的内容

      "latex-workshop.view.pdf.viewer": "tab",
      "latex-workshop.latex.recipes": [
      {
          "name": "xelatex",
          "tools": [
              "xelatex"
          ]
      }, 
      {
          "name": "latexmk",
          "tools": [
              "latexmk"
          ]
      },
      {
          "name": "pdflatex -> bibtex -> pdflatex*2",
          "tools": [
              "pdflatex",
              "bibtex",
              "pdflatex",
              "pdflatex"
          ]
      }],
      "latex-workshop.latex.tools": [
      {
          "name": "latexmk",
          "command": "latexmk",
          "args": [
              "-synctex=1",
              "-interaction=nonstopmode",
              "-file-line-error",
              "-pdf",
              "%DOC%"
          ]
      },
      {
          "name": "xelatex",
          "command": "xelatex",
          "args": [
              "-synctex=1",
              "-interaction=nonstopmode",
          "-file-line-error",
          "%DOC%"
          ]
      },
      {
          "name": "pdflatex",
          "command": "pdflatex",
          "args": [
              "-synctex=1",
              "-interaction=nonstopmode",
              "-file-line-error",
              "%DOC%"
          ]
      },
      {
          "name": "bibtex",
          "command": "bibtex",
          "args": [
              "%DOCFILE%"
          ]
      }],
      "latex-workshop.latex.clean.fileTypes": [
          "*.aux",
          "*.bbl",
          "*.blg",
          "*.idx",
          "*.ind",
          "*.lof",
          "*.lot",
          "*.out",
          "*.toc",
          "*.acn",
          "*.acr",
          "*.alg",
          "*.glg",
          "*.glo",
          "*.gls",
          "*.ist",
          "*.fls",
          "*.log",
          "*.fdb_latexmk"
      ]  
    

    在 VSCode 中打开 test.tex 文件,可以 build,并在 build 完成后使用 VSCode 预览。

  • 相关阅读:
    JVM内存结构解析
    tomcat服务器日志分页
    20多个常用的免费WebService接口
    将tomcat设置在服务中为开机自动启动
    oracle11g安装常见错误
    Resultset 转化成list或map
    SprngMVC工作原理
    Spring中ContextLoaderListener作用
    oracle如何导出和导入数据库/表
    轻松搭建Redis缓存高可用集群
  • 原文地址:https://www.cnblogs.com/xqmeng/p/13931222.html
Copyright © 2011-2022 走看看