-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imgmath生成ロジックの改良 #868
Comments
数式中の日本語表示について、別の案件で、メソッド def make_math_image(str, path, fontsize = 10) # 12
fontsize2 = (fontsize * 1.2).round.to_i
texsrc = <<-EOB
\\documentclass[10pt,uplatex]{jsarticle}
\\RequirePackage[utf8]{inputenc}
\\RequirePackage[prefernoncjk]{pxcjkcat}
\\cjkcategory{sym18,sym19,grek}{cjk}
\\usepackage{amsmath}
%%\\usepackage{amsthm}
\\usepackage{amssymb}
\\usepackage{amsfonts}
\\usepackage{anyfontsize}
\\usepackage{bm}
\\pagestyle{empty}
\\begin{document}
\\fontsize{#{fontsize}}{#{fontsize2}}\\selectfont #{str}
\\end{document}
EOB
Dir.mktmpdir do |tmpdir|
tex_path = File.join(tmpdir, 'tmpmath.tex')
dvi_path = File.join(tmpdir, 'tmpmath.dvi')
pdf_path = File.join(tmpdir, 'tmpmath.pdf')
File.write(tex_path, texsrc)
##
## * latex -> uplatex: destroy the LaTeX typesetting log
## * dvipng -> sips (pre-installed in macOS): set output resolution to 144 dpi
# system("latex --interaction=nonstopmode --output-directory=#{tmpdir} #{tex_path} 2>&1 >/dev/null && dvipng -D 144 -T tight -z9 -o #{path} #{dvi_path}")
system("uplatex --interaction=nonstopmode --output-directory=#{tmpdir} #{tex_path} 2>&1 >/dev/null && dvipdfmx -o - #{dvi_path} | pdfcrop - #{pdf_path} && magick -density 200x200 #{pdf_path} #{path}")
out, status = Open3.capture2e(cmd)
unless status.success?
error "latex compile error\n\nError log:\n" + out
end
end
end |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
軽量なドキュメントならこれでもいいのかもだけど。
「呼び出し都度」「日本語不可」が大きめの問題。dviからでなくpdfまで作って切り出す方法なら日本語もいけるのだが、都度だと無駄な時間がかかる。
The text was updated successfully, but these errors were encountered: