zoukankan      html  css  js  c++  java
  • 安装 texlive

    多系统使用texlive

    中文latex

    1. 用xelatex 编译

    只需要加入宏包

    usepackage[UTF8]{ctex}
    

    Rmarkdown 配置模版

    $ cat _output.yaml
    beamer_presentation:
      theme: Warsaw
      colortheme: dove
      toc: true
      keep_tex: false
      latex_engine: xelatex
      incremental: no
      includes:
        in_header: _header.tex
    
    $ cat _header.tex
    %usepackage[fontset=windows,UTF8]{ctex}
    usepackage[UTF8]{ctex}
    logo{includegraphics[height=0.09	extwidth]{logo/zhima.png}}
    
    $ cat zhima20161124.Rmd
    ---
    title: 题目
    author: |
      | 作者
      | 单位
    date: 	oday
    ---
    
    …… 
    
    

    安装texlive2016

    sudo yum install perl-Digest-MD5
    
    sudo mount  -o loop texlive2016.iso /mnt
    sudo ./install-tl 
    sudo umount /mnt
    
    sudo vim  /etc/bashrc 
    sudo vim /usr/lib64/R/etc/Renviron 
    
    tar -zxvf winfont.tgz 
    sudo mv usr/local/texlive/texmf-local/fonts/truetype  /usr/local/texlive/texmf-local/fonts/ 
    sudo fc-list
    sudo texhash 
    

    安装 texlive2015

    复制windows字体

    $ls /usr/local/texlive/texmf-local/fonts/truetype/ -hl
    total 61M
    -rw-r--r-- 1 root root  11M Dec 16 19:55 simfang.ttf
    lrwxrwxrwx 1 root root   11 Dec 16 19:57 SIMFANG.TTF -> simfang.ttf
    -rw-r--r-- 1 root root 9.4M Dec 16 19:55 simhei.ttf
    -rw-r--r-- 1 root root  12M Dec 16 19:55 simkai.ttf
    lrwxrwxrwx 1 root root   10 Dec 16 19:57 SIMKAI.TTF -> simkai.ttf
    -rw-r--r-- 1 root root 8.8M Dec 16 19:55 simli.ttf
    -rw-r--r-- 1 root root  15M Dec 16 19:55 simsun.ttc
    -rw-r--r-- 1 root root 6.4M Dec 16 19:55 simyou.ttf
    

    使用ctex

    • ctex 修改 documentclass
     documentclass[UTF8, hyperref,fontset=windows]{ctexart}
    

    或 增加引用ctex包

    usepackage[fontset=windows,UTF8]{ctex}
    
    • Rmarkdown模板

    修改文件头 /usr/lib64/R/library/rmarkdown/rmd/latex/default.tex

    documentclass[...,$endfor$,hyperref,UTF8, fontset=windows]{ctexart}
    %documentclass[...,$endfor$]{$documentclass$}
    

    cat slidy.Rmd
    ---
    title: 题目
    author: |
      | 作者
      | 单位
    date: 	oday
    fontfamily: ctex
    fontfamilyoptions: fontset=windows,UTF8
    ---
    

    或用yaml 模版,(注意,用xelatex 选项,不依赖系统)

    $ cat _output.yaml
    beamer_presentation:
      theme: Warsaw
      colortheme: dove
      toc: true
      keep_tex: false
      latex_engine: xelatex
      incremental: no
      includes:
        in_header: _header.tex
    
    $ cat _header.tex
    %usepackage[fontset=windows,UTF8]{ctex}
    usepackage[UTF8]{ctex}
    logo{includegraphics[height=0.09	extwidth]{logo/zhima.png}}
    
    $ cat zhima20161124.Rmd
    ---
    title: 题目
    author: |
      | 作者
      | 单位
    date: 	oday
    ---
    
    …… 
    
    
    • jupyter文件

    修改模版文件 base.tplx

    sed -i '/usepackage{graphicx}/a      \\usepackage[UTF8,fontset=windows]{ctex}' base.tplx
    
    

    调用函数, 注意 用xelatex, pdflatex失败

    import nbformat
    from nbconvert.exporters import (HTMLExporter, PDFExporter)
    from nbformat.v4 import new_markdown_cell
    
    exporter = PDFExporter(latex_count=2, latex_command = [u"xelatex", u"{filename}"])
    exporter.default_template_path = '/home/keke.zhaokk/.jupyter/nbconvert/templates/latex'
    
    nb_json = nbformat.read("/home/yan.xi/public/test1.ipynb", as_version=4)
    (body, resources) = exporter.from_notebook_node(nb_json)
    

    系统文件路径

    $#sudo vim /opt/anaconda3/lib/python3.4/site-packages/nbconvert/exporters/pdf.py
    $# .../nbconvert/templates/latex/base.tplx 
    

    对于windows,或者texlive早期版本,只修改模版就好。

    字体相关的命令

    sudo fc-list
    sudo texhash 
    #sudo  mktexlsr
    

    matplot画图的中文问题

    sudo mkdir -p /usr/share/fonts/chinese/TrueType/
    sudo cp  /usr/local/texlive/texmf-local/fonts/truetype/simsun.ttc  /usr/share/fonts/chinese/TrueType/
    sudo cp  /usr/local/texlive/texmf-local/fonts/truetype/simhei.ttf  /usr/share/fonts/chinese/TrueType/
    sudo fc-cache  /usr/share/fonts/chinese/TrueType
    fc-list
    sudo vim /opt/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc
    

    补充(mac)

    把字体挪到 系统目录, 执行texhash 即可

    sudo mv  truetype  /usr/local/texlive/texmf-local/fonts/
    sudo texhash
    

    --- 她说, 她是仙,她不是神
  • 相关阅读:
    软件性能测试知识汇总
    软件功能测试知识汇总
    机器学习——KNN算法(k近邻算法)
    Shell脚本语法
    机器学习环境搭建及基础
    shell基础及变量
    查准率和召回率理解
    python中的矩阵、多维数组
    链表:反转链表
    栈和队列:生成窗口最大值数组
  • 原文地址:https://www.cnblogs.com/bregman/p/5064237.html
Copyright © 2011-2022 走看看