在windows上使用MinGW+MSYS,可以编辑自己的命令脚本,简化命令行。以下是几个例子。
调用notepad++打开文本
编辑 /bin/npp,脚本代码:
#!/bin/sh /d/Program\ Files/Notepad++/notepad++.exe "$@"
调用方式:
$ npp /bin/npp &
调用gvim打开文本
同理,编辑 /bin/gv:
#!/bin/sh /d/Program\ Files/Vim/vim73/gvim.exe "$@"
调用pandoc生成pdf
由于我的pandoc不能直接生成pdf,报错如下,一直无法解决:
pandoc.exe: Error producing PDF from TeX source.
! I can't find file `C:/Users/ADMIN'.
<to be read again>
\protect
<*> C:/Users/ADMIN~
1/AppData/Local/Temp/tex2pdf.9500/input.tex
(Press Enter to retry, or Control-Z to exit)
Please type another input file name
! Emergency stop.
<to be read again>
\protect
<*> C:/Users/ADMIN~
1/AppData/Local/Temp/tex2pdf.9500/input.tex
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on C:\Users\ADMIN~1\AppData\Local\Temp\tex2pdf.9500/texput.
log.
所以考虑分两步解决:先转换成tex,在用pdflatex转换成pdf。编辑/bin/pdf:
#!/bin/bash
if [ ! -d $1.tmp ]; then
mkdir $1.tmp
fi
pandoc -s $1 -o $1.tex
cd $1.tmp
mv ../$1.tex ./
cat $1.tex | sed '2 i\\\usepackage{CJKutf8}' | sed '/begin{document}/ a\\\begin{CJK}{UTF8}{gbsn}' | sed '/end{document}/ i\\\end{CJK}'>tmp.tex
#iconv -f gbk -t utf-8 tmp.tex
pdflatex tmp.tex
mv tmp.pdf ../
同理pandoc生成其他格式也可以这么处理,如编辑 /bin/doc:
#!/bin/bash pandoc -s $1 -o $1.docx
pandoc直接生成pdf报错的原因:I think we know what is happening now. Since your usernameis > 8 characters, Windows uses the `~` in the path name, andthat screws up LaTeX.Still not sure how to fix it. FROM:https://github.com/jgm/pandoc/issues/777#issuecomment-16909078