chenyi852 / chenyi852.github.com

It's my first blog
Apache License 2.0
0 stars 0 forks source link

how to convert from md to pdf #5

Closed chenyi852 closed 5 years ago

chenyi852 commented 5 years ago
sudo apt-get install pandoc texlive-latex-base texlive-fonts-recommended texlive-extra-utils
pandoc -t beamer -o output.pdf yourInput.md
chenyi852 commented 5 years ago

Ubuntu 安装 Latex 已及中文包

1你可以在 Ubuntu 安装很多 LaTeX 的分发版,其中一个是 TeX Live。

sudo apt-get install texlive-full

2 中文包:sudo apt-get install latex-cjk-all

3 .sty : sudo apt-get install texliver-latex-extra

4 要编辑 LaTeX 文档需要一个编辑器,你可以找到很多编辑器,这里我们推荐 Texmaker

sudo apt-get install texmaker

5 在 Ubuntu 下执行下面命令可以打开 Texmaker 编辑器

texmaker

6 现在让我们用 Texmaker 创建一个简单的文档,点击 File -> New 然后在新文档中插入如下内容:

\documentclass{article}

\begin{document}

  Hello oschina!

\end{document}

7 接下来使用 File -> Save 将文档保存为一个扩展名为 tex 的文件,然后点击 Quick Build 来编译文档:

8 测试中文

\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{gkai}
这是一个楷体中文测试,处理简体字。
\end{CJK}
\begin{CJK}{UTF8}{gbsn}
这是一个宋体中文测试,处理简体字。
\end{CJK}
\begin{CJK}{UTF8}{bkai}
這是一個big5編碼的楷體中文測試,處理繁體文字。
\end{CJK}
\begin{CJK}{UTF8}{bsmi}
這是一個个big5編碼的明體中文測試,處理繁體文字。
\end{CJK}
\end{document}
chenyi852 commented 5 years ago

pandoc: xelatex not found. xelatex is needed for pdf output

sudo apt-get install texlive-xetex
chenyi852 commented 5 years ago

字体找不到

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "Noto Sans CJK" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................

l.16     \setmainfont[]{Noto Sans CJK}

1 Download the fonts to use (I used Noto Sans CJK) 2 Put the font files (.otf) in /usr/local/share/fonts 3 After rebooting, use this line to tell XeLaTeX to get those fonts: \setCJKmainfont{Noto Sans CJK SC}

chenyi852 commented 5 years ago

md to pdf

pandoc -f markdown_github chenyi-cv.md -o chenyi-cv.pdf --latex-engine=xelatex -V mainfont="NotoSansSC-Regular"

chenyi852 commented 5 years ago

md 转 pdf的效果不太好, 主要是不支持自动换行,字体要自己安装下载指定,不能自动识别系统自动。 如果实在不行用word,可以是考虑使用latex