• vim+make+okular实现latex文档的编辑,编译和查看


    环境:依旧是manjaro 最新版本:假设目录结构为~/latexCode目录下有目录src和latex源码:hello.tex和Makefile文件

    首先,用vim编辑源码如下,文件名称:hello.tex:

    #fileName: hello.tex
    
     1 \documentclass{ctexart}                                                                                            
     2 \begin{document}
     3 Hello world! from \LaTeX.
     4 \\我是谁,我在哪里?
     5 \end{document}

    接着编写makefile文件,名称Makefile:

    # fileName: Makefile
     1 #FILENAME=hello
     2 ${FILENAME}.pdf:${FILENAME}.dvi
     3     dvipdfm $^ -o $@
     4 ${FILENAME}.dvi:${FILENAME}.tex
     5     latex $^
     6 clean:
     7     @rm ${FILENAME}.log
     8     @rm ${FILENAME}.dvi
     9     @rm ${FILENAME}.pdf
    10     @rm ${FILENAME}.aux
    11     @mv ${FILENAME}.tex src/                                                                                       
    12     @echo clean finished!
    ~                            

    然后打开终端,cd ~/latexCode

    make FILENAME=hello 

    此处的hello和你自己的源文件名称前缀一致即可,不懂就看下make文档

    中间过程为:

     1 latex hello.tex
     2 This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/Arch Linux) (preloaded format=latex)
     3  restricted \write18 enabled.
     4 entering extended mode
     5 (./hello.tex
     6 LaTeX2e <2021-11-15> patch level 1
     7 L3 programming layer <2022-04-10>
     8 (/usr/share/texmf-dist/tex/latex/ctex/ctexart.cls
     9 (/usr/share/texmf-dist/tex/latex/ctex/config/ctexbackend.cfg)
    10 (/usr/share/texmf-dist/tex/latex/l3kernel/expl3.sty
    11 (/usr/share/texmf-dist/tex/latex/l3backend/l3backend-dvipdfmx.def))
    12 Document Class: ctexart 2021/12/12 v2.5.8 Chinese adapter for class article (CT
    13 EX)
    14 (/usr/share/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
    15 (/usr/share/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
    16 (/usr/share/texmf-dist/tex/latex/ctex/ctexhook.sty)
    17 (/usr/share/texmf-dist/tex/latex/ctex/ctexpatch.sty)
    18 (/usr/share/texmf-dist/tex/latex/base/fix-cm.sty
    19 (/usr/share/texmf-dist/tex/latex/base/ts1enc.def))
    20 (/usr/share/texmf-dist/tex/latex/ctex/config/ctexopts.cfg)
    21 
    22 Package ctex Warning: UTF8 will be used as the default encoding.
    23 
    24 (/usr/share/texmf-dist/tex/latex/base/article.cls
    25 Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
    26 (/usr/share/texmf-dist/tex/latex/base/size10.clo))
    27 (/usr/share/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def
    28 (/usr/share/texmf-dist/tex/latex/cjk/texinput/CJKutf8.sty
    29 (/usr/share/texmf-dist/tex/generic/iftex/ifpdf.sty
    30 (/usr/share/texmf-dist/tex/generic/iftex/iftex.sty))
    31 (/usr/share/texmf-dist/tex/latex/base/inputenc.sty)
    32 (/usr/share/texmf-dist/tex/latex/cjk/texinput/CJK.sty
    33 (/usr/share/texmf-dist/tex/latex/cjk/texinput/mule/MULEenc.sty)
    34 (/usr/share/texmf-dist/tex/latex/cjk/texinput/CJK.enc))
    35 (/usr/share/texmf-dist/tex/latex/base/fontenc.sty))
    36 (/usr/share/texmf-dist/tex/latex/cjkpunct/CJKpunct.sty
    37 (/usr/share/texmf-dist/tex/latex/cjkpunct/CJKpunct.spa))
    38 (/usr/share/texmf-dist/tex/latex/cjk/texinput/CJKspace.sty)
    39 (/usr/share/texmf-dist/tex/latex/ctex/ctexspa.def))
    40 (/usr/share/texmf-dist/tex/latex/zhnumber/zhnumber.sty
    41 (/usr/share/texmf-dist/tex/latex/zhnumber/zhnumber-utf8.cfg))
    42 (/usr/share/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-article.def
    43 (/usr/share/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg))
    44 (/usr/share/texmf-dist/tex/latex/ctex/ctex-c5size.clo)
    45 (/usr/share/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-fandol.def))
    46 (/usr/share/texmf-dist/tex/latex/ctex/config/ctex.cfg)
    47 (/usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.bdg)
    48 (/usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.enc)
    49 (/usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.chr)
    50 No file hello.aux.
    51 (/usr/share/texmf-dist/tex/latex/ctex/fd/c70rm.fd)
    52 (/usr/share/texmf-dist/tex/generic/ctex/zhmap/ctex-zhmap-fandol.tex) [1]
    53 (./hello.aux) )
    54 Output written on hello.dvi (1 page, 1984 bytes).
    55 Transcript written on hello.log.
    56 dvipdfm hello.dvi -o hello.pdf
    57 hello.dvi -> hello.pdf
    58 [1]
    59 7477 bytes written

      可能不尽相同,但只要成功即可,成功后,latexCode下多出文件:hello.aux  hello.dvi  hello.log  hello.pdf,

    再此,可用用okular hello.pdf查看文件效果,如果可以就可以了,否则,就修改hello.tex文件再编译,直到效果达到需要的结果即可。

    最后,清除多余的文件:

    make FILENAME=hello clean

    当看到clean finished!后,就把除了源文件之外的文件,包括pdf文件一起删除了,并且将hello.tex文件移动到src目录下面保护了起来了,如果觉得不是你需要的效果,请自行修改Makefile文件即可,非常容易,不再多说。

    其时,假设目录结构为:~/latexCode下面有两个目录pdf   src和Makefile文件

    修改Makefile文件内容:

     1 #FILENAME=hello
     2 OBJ_DIR = ./pdf
     3 SRC_DIR = ./src
     4 ${OBJ_DIR}/${Filename}.pdf:${Filename}.dvi
     5     dvipdfm $^ -o $@
     6 ${Filename}.dvi:${SRC_DIR}/${Filename}.tex
     7     latex $^
     8 clean:
     9     @rm ${Filename}.log
    10     @rm ${Filename}.dvi
    11     @rm ${Filename}.aux
    12 #   @mv ${Filename}.pdf pdf/                                                                                       
    13 #   @mv ${Filename}.tex src/
    14     @echo clean finished!

    编译方式,依旧是make Filename=hello就在pdf目录生成了hello.pdf文件,此时的源文件hello.tex在src目录下,这样目录结构更加清晰,临时文件就在当前目录下,结束后只要执行make Filename=hello clean清理下就把所有的临时文件清除了。基本达到了可用的状态了吧

  • 相关阅读:
    牌库读取的修复
    法术迸发(Spellburst)
    传染孢子的探索
    降低电脑功耗——降低笔记本风扇噪音
    Playfield 类方法的注释
    大陆争霸( 最短路变形)
    POJ 2406 Power String
    括号匹配
    HDU 1003 最大子段和
    6.19noip模拟赛总结
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/16379074.html
Copyright © 2020-2023  润新知