Configure Latex environment under Ubuntu (Linux)

1. Causes and causes

I first came into contact with Latex because I wanted to typeset mathematical modeling papers with Latex. Recently I have written a lot of math notes with Latex, which are very neat and beautiful. I also want to typeset some upcoming papers with Latex. Just download the CTex suite under Windows and install it, which is very convenient, but the installation time is not generally long! Recently I started to use the Linux system, and I fought with the Latex compilation environment under Ubuntu. It's easier to use.
  A brief introduction to Latex, I don't need to look up the information. I have to remember and understand it.

2. Introduction to Latex

Developed by the American computer scientist Leslie Lamport in the early 1980s, using this format, even users without knowledge of typesetting and programming can give full play to the powerful functions provided by TeX , Can generate many book-quality printed materials within days or even hours. This is particularly prominent for generating complex tables and mathematical formulas. Therefore, it is very suitable for generating high-quality technical and mathematical documents. By writing documents through Latex and then compiling, high-quality PDF documents can be generated, which is more flexible and usable than word. I often use the ubuntu system, and there may be other friends who will use other versions of the system, but the installation of Latex in each version of Linux is similar, the following describes how to configure the Latex compilation environment in ubuntu.

3.Latex installation process

Install textlive

sudo apt-get install texlive-full
# 安装时间有点长,其中的xetex集成了中文字体的环境,使得中文文档的生成变得很容易,可以使用系统自带得字体,使用更好看得字体。
apt-cache search cjk
# 找到相关宏包,安装

I found some of the following font files in the author's computer and
Screenshotexecuted the following commands

sudo apt-get install latex-cjk-xcjk cjk-latex latex-cjk-chinese

In order to better integrate into the Ubuntu system, we add font files under the Windows system to Ubuntu. Create a folder:

sudo mkdir /usr/share/fonts/winfonts

Copy the font files in Windows to the folder /usr/share/fonts/winfonts, and refresh the font library.

cd /usr/share/fonts/winfonts
sudo mkfontscale
sudo mkfontdir
# 刷新字体缓存
sudo fc-cache -vf

By using custom fonts, Chinese configuration, encoding options, etc. Make LaTeX support Chinese, of course XeTeX natively supports Chinese. This is the reason why individuals prefer to configure the xelatex environment. Test the following documents

\documentclass{article}
\usepackage[a4paper, left=1in, right=1in, top=1in, bottom=1in]{geometry}
\usepackage{xeCJK} %调用 xeCJK 宏包
\usepackage{listings}
\author{ ice }
\date {2019.01.28}
\setmainfont{SimSun}   % 宋体
%\setCJKmainfont{WenQuanYi Micro Hei Mono:style=Regular} %设置 CJK 主字体为 SimSun (宋体)
\title{Latex入门学习}
\begin{document}
\maketitle
\begin{center}
\end{center}

\tableofcontents %添加目录

\tableofcontents 

\begin{abstract}
this is abstract。
\end{abstract}

\section{asf}
你好。

\section{as}
hello world  

% Lorem  \cite{Lutz2017} ipsum dolor sit amet, consectetur adipisicing

% \bibliography{info}
\bibliographystyle{ieeetr}

\end{document}

Enter the following compilation command in the command line

xelatex test.tex

That can be compiled successfully

4. Configure Latex environment in VSCode

VSCode is my most commonly used software for writing code. Search for latex in the extensions bar (Extensions), and install
VScode LatexOpen File->Preference->Settings and edit settings.json, add the following content (for reference only)


{
    
    
  "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.view.pdf.viewer": "tab",
"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"
],
}

Save the configuration and restart VSCode.

reference

[1] Linux configuration VS Code Latex environment
[2] LaTeX Chinese typesetting (using XeTeX)
[3] Linux (Ubuntu) configuration Latex environment
[4] Ubuntu18.04 vscode configuration latex environment

Guess you like

Origin blog.csdn.net/Zhang_Pro/article/details/106988187