0%

LaTeX环境+开源项目

2019年12月9日 下午4:40

MacTex:安装位置
"texpath" : "$PATH:/Library/TeX/texbin:/usr/texbin:/usr/local/bin:/opt/local/bin"

latex+vim

How I’m able to take notes in mathematics lectures using LaTeX and Vim | Gilles Castel

macTex + sublime + skim : 成功

如何用 macOS 优雅的敲 LaTeX - 简书
Mac OS 配置 LaTeX 环境 - 少数派
科学网—Latex学习常见错误一 - 鄂得俊的博文

问题原因:

  • 现在网上好多的模板或者期刊模板都是采用xeLatex进行编译的,但是sublime+Latex默认编译方式为pdfLatex,这就需要对我们的配置文件进行修改,才能使我们的文件编译通过,具体的步骤如下:

    解决方案: 学会如何改变编译器

  1. 选择Preferences --->Browse Packages… —>LatexTools —>Reset user settings to default
  2. 选择Preferences --->Browse Packages… —>LatexTools —>LatexTools.sublime-settings
  3. 搜索(ctrl+F)找到”builder”:””default”,将default修改为basic,保存退出
  4. 需要注意:如果我们按ctrl+B依旧会报错,需要采用ctrl+shift+P —>build —>Build With: Latex-Basic Builder- XeLatex
    1. 这句话最关键
  5. ctrl + b进行编译,在skim中就可以显示

测试代码

1
2
3
4
5
6
7
8
9
10
11
%!TEX program = xelatex
\documentclass{article}
\usepackage{fontspec, xunicode, xltxtra}
\setmainfont{Hiragino Sans GB}
\title{Title}
\author{}
\begin{document}
\maketitle{}
\section{Introduction}
This is where you will write your content
\end{document}

macTex + VScode:成功——更好用一些

配置 VSCode 作为LaTex 编辑器 - 简书

  1. Latex有很多编译方式, 比如pdflatex, latexmk, pdftex等等. 这里我使用的编译方式是xelatex, 它使用的是utf-8编码方式, 原生就支持中文, 只要选择好了字体, 可以直接编译中文.
  2. 宏包就像C语言这样: #include <stdio.h>, 和别的编程语言import之类的引用其他包的方式很相似.
  3. ctex的使用也很简单, 直接\usepackage{ctex}就可以了. 注意这是xelatex的编译方式才可以, 其他的编译方式可能会失败. pdflatex的编译方式要这样写\documentclass[UTF8]{article}, 来表明编码方式是utf-8.

开源项目学习latex语法

【开源项目】LaTeX速查手册.pdf - 知乎

  1. 安装python依赖,用于使用代码解析模块mint
    1. pip3 install pygments
  2. 代码需要修改三处:
    1. usepackage[UTF8,fontset=macnew,heading=true]{ctex}
    2. \setCJKmainfont[ItalicFont=STKaiti]{STSong}

参考文章:

  1. LaTeX中Python代码的语法高亮 - hzworld - 博客园
  2. LaTeX技巧791:如何配置 MacTeX 的中文支持?
  3. 字符集下载网站:FREE Fonts To Download - Thousands of fonts to download free for windows and mac
  4. 关于字体的依赖找不到:
    1. latex是一门语言,但他不是跨平台的!
    2. mac下使用xelatex模板找不到自字体如何解决? - 知乎
    3. 如果模板是基于ctex的,
      1. 删去winfonts、fontset=windows之类字体选项即可;
    4. 如果模板是用setCJKmainfont等命令直接设置字体的
      1. 可以自己改为Mac系统预装的华文宋体、黑体、楷体、仿宋

vs 配置页内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
“latex-workshop.latex.recipes”: [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
“name”: “xe->bib->xe->xe”,
“tools”: [
“xelatex”,
“bibtex”,
“xelatex”,
“xelatex”
]
}
],
“latex-workshop.latex.tools”: [
{
// 编译工具和命令
“name”: “xelatex”,
“command”: “xelatex”,
“args”: [
“-synctex=1”,
“-shell-escape”,
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
“-synctex=1”,
“-interaction=nonstopmode”,
“-file-line-error”,
“%DOCFILE%”
]
},
{
“name”: “bibtex”,
“command”: “bibtex”,
“args”: [
“%DOCFILE%”
]
}
],
“latex-workshop.view.pdf.viewer”: “external”,
“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”
],
}