Last active
November 6, 2015 11:20
-
-
Save ssh0/af3decc647a24bb562e4 to your computer and use it in GitHub Desktop.
プレゼンで使う数式画像を作成する[vim + vim-quickrun + latexmk + dvipng] ref: http://qiita.com/ssh0/items/2113db858ba5c9fd05df
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
$latex = 'platex -interaction=nonstopmode -kanji=utf-8 %O %S'; | |
$pdf_mode = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
augroup texmath | |
autocmd! | |
autocmd FileType texmath setlocal syntax=tex | |
augroup END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[43pt]{jsarticle} | |
\usepackage{amsmath} | |
\usepackage{amssymb} | |
\usepackage{amsthm} | |
\usepackage{ascmac} | |
\pagestyle{empty} | |
% "\vector{a}" でベクトル | |
\def\vector#1{\mbox{\boldmath \(#1\)}} | |
\begin{document} | |
\begin{align*} | |
f(x) &= \int^{\infty}_{-\infty}\mathrm{d}x \frac{\sin x}{x} \\ | |
&= \pi | |
\end{align*} | |
\newpage | |
$\vector{x} = (x_{1}, x_{2})$ | |
\newpage | |
$\mathcal{C}$ | |
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
platex fig_test.tex | |
dvipng -T tight -bd 1000 fig_test.dvi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
texmath fig_test.tex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[43pt]{jsarticle} | |
\usepackage{amsmath} | |
\usepackage{amssymb} | |
\usepackage{amsthm} | |
\usepackage{ascmac} | |
\pagestyle{empty} | |
% "\vector{a}" でベクトル | |
\def\vector#1{\mbox{\boldmath \(#1\)}} | |
\begin{document} | |
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" LaTeX Quickrun (texmath) | |
let g:quickrun_config['texmath'] = { | |
\ 'runner' : 'vimproc', | |
\ 'command' : 'texmath', | |
\ 'outputter' : 'error', | |
\ 'outputter/error/success' : 'null', | |
\ 'outputter/error/error' : 'quickfix', | |
\ 'srcfile' : expand("%s"), | |
\ 'exec': '%c %s', | |
\} | |
augroup latex_autocompile | |
autocmd! | |
if g:quickrun_user_tex_autorun != 0 | |
autocmd BufWritePost,FileWritePost *.tex :QuickRun | |
autocmd BufWritePost,FileWritePost fig*.tex :QuickRun -type texmath | |
endif | |
augroup END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# written by Shotaro Fujimoto (https://github.com/ssh0) | |
# first edited: 2015-11-03 | |
# using latexmk rc file | |
latexmkrc="$HOME/.latexmkrc_dvipng" | |
usage() { | |
cat <<EOF | |
NAME | |
texmath - compile latex to png with dvipng (and create texmath file) | |
USAGE | |
texmath [-e FILE | FILE] [-h] | |
ARGUMENTS | |
-e FILE: Open and edit FILE. | |
Or create it when FILE doesn't exist, | |
FILE: If you provide only file name, this script compiles the file with | |
latexmk and then creates png file by dvipng. | |
--help: Display this help and exit | |
EOF | |
exit 1 | |
} | |
texmathtemplate="$(cat <<EOF | |
% vim: ft=texmath | |
\documentclass[43pt]{jsarticle} | |
\usepackage{amsmath} | |
\usepackage{amssymb} | |
\usepackage{amsthm} | |
\usepackage{ascmac} | |
\pagestyle{empty} | |
% '\vector{a}' でベクトル | |
\def\vector#1{\mbox{\boldmath \(#1\)}} | |
\begin{document} | |
\begin{eqnarray*} | |
\end{eqnarray*} | |
\newpage | |
\end{document} | |
EOF | |
)" | |
if [ "$1" = "-h" ]; then | |
usage | |
elif [ "$1" = "-e" ]; then | |
if [ -f "$2" ]; then | |
texfile="$2" | |
elif [ ! "$2" = "" ]; then | |
texfile="$2" | |
echo "$texmathtemplate" > "$texfile" | |
else | |
echo "Option '-e' needs a file name to edit." | |
echo "Aborted." | |
exit 1 | |
fi | |
vim "$texfile" | |
elif [ ! -f "$1" ]; then | |
echo "'$1' doesn't exist." | |
echo "Aborted." | |
exit 1 | |
elif [ -f "$1" ]; then | |
texfile="$1" | |
latexmk -r "$latexmkrc" "${texfile}" \ | |
&& latexmk -c "${texfile}" \ | |
&& dvipng -T tight -bd 1000 "${texfile%.tex}.dvi" \ | |
&& rm *.fls | |
else | |
usage | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" LaTeX Quickrun (texmath) | |
let g:quickrun_config['texmath'] = { | |
\ 'runner' : 'vimproc', | |
\ 'command' : 'texmath', | |
\ 'outputter' : 'error', | |
\ 'outputter/error/success' : 'null', | |
\ 'outputter/error/error' : 'quickfix', | |
\ 'srcfile' : expand("%s"), | |
\ 'exec': '%c %s', | |
\} | |
augroup texmath_autocompile | |
autocmd! | |
autocmd BufWritePost,FileWritePost *.tex :QuickRun | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment