Skip to content
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のfontsize/lineheightをtexequationにも適用する #1146

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/review/htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ def texequation(lines)
p = MathML::LaTeX::Parser.new(symbol: MathML::Symbol::CharacterReference)
puts p.parse(unescape(lines.join("\n")), true)
elsif @book.config['imgmath']
math_str = "\\begin{equation*}\n" + unescape(lines.join("\n")) + "\n\\end{equation*}\n"
math_str = "\\begin{equation*}\n" + "\\begin{block_equation}\n" +
unescape(lines.join("\n")) +
"\n\\end{block_equation}\n" + "\\end{equation*}\n"
key = Digest::SHA256.hexdigest(math_str)
math_dir = File.join(@book.config['imagedir'], '_review_math')
Dir.mkdir(math_dir) unless Dir.exist?(math_dir)
Expand Down
23 changes: 23 additions & 0 deletions lib/review/makerhelper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,38 @@ def default_imgmath_preamble
EOB
end

def equation_block_style(f,h)
<<-EOB
\\newenvironment{block_equation}
{
\\fontsize{#{f}}{#{h}}\\selectfont
}
{
}
EOB
end

def make_math_images(math_dir)
fontsize = @config['imgmath_options']['fontsize'].to_f
lineheight = @config['imgmath_options']['lineheight'].to_f

block_fontsize = fontsize
block_lineheight = lineheight
if @config['imgmath_options']['block_fontsize']
block_fontsize = @config['imgmath_options']['block_fontsize']
end
if @config['imgmath_options']['block_lineheight']
block_lineheight = @config['imgmath_options']['block_lineheight']
end

texsrc = default_imgmath_preamble

if @config['imgmath_options']['preamble_file'] && File.readable?(@config['imgmath_options']['preamble_file'])
texsrc = File.read(@config['imgmath_options']['preamble_file'])
end

texsrc << equation_block_style(block_fontsize, block_lineheight)

texsrc << <<-EOB
\\begin{document}
\\fontsize{#{fontsize}}{#{lineheight}}\\selectfont
Expand Down