Solve the problem of missing Chinese fonts in latex compilation under Ubuntu

1. Introduction
  • latex + vscodeThe editing environment is installed in Ubuntu 18.04 as recorded in the previous blog .
  • There is no problem when compiling the English document, but when compiling the graduation thesis with Chinese, an error occurs:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
./thesis-uestc.cls:58: fontspec error: "font-not-found"
! 
! The font "simhei" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  
                                                  
l.58   \newfontfamily{
    
    \heiti@letter}{
    
    simhei.ttf}
  • Checking the relevant documents, I found that the simhei.ttfcorresponding Chinese boldface under the windows system .
  • Many blogs have pointed out that latex support for Chinese fonts under Ubuntu is not very friendly. It is necessary to copy Chinese fonts from the windows system to solve the problem.
2. Solve the problem of missing fonts
① Check if there are missing fonts in the Ubuntu system
  • Sometimes, the lack of a font may be that the Ubuntu system does not have the font, or it may exist, but it is not placed in the corresponding folder.
  • Enter the following command to view the Chinese fonts in the Ubuntu system:
$ fc-list :lang=zh

Insert picture description here-Look for the missing ones in the output results and find simhei.ttfthat they are not.

② Download missing fonts from the Internet
  • Enter Baidu to simhei.ttf 下载find resources that can be downloaded. I chose the first one in the search results.
    Insert picture description here
  • After the download is complete, add the compressed file to get the simhei.ttffile.
    Insert picture description here
③ Complete font installation
  • Create a folder /usr/share/fonts/winfontsto store missing fonts:
$ sudo mkdir /usr/share/fonts/winfonts
  • Change folder permissions:
$ sudo chmod -R 0777 /usr/share/fonts/winfonts
  • Copy the missing fonts to the directory you just created:
$ sudo cp -rf simhei.ttf /usr/share/fonts/winfonts
  • Refresh the font library:
$ sudo mkfontscale
$ sudo mkfontdir
$ sudo fc-cache -fsv
  • Compile again and find that the simhei.ttfmissing problem has been solved!

Reference document: Install and compile LaTex under Ubuntu

Guess you like

Origin blog.csdn.net/u014454538/article/details/104503211