kmuto’s blog

はてな社でMackerel CREをやっています。料理と旅行といろんなIT技術

技術書典15に向けて『Hatena Tech Book Vol.2』を作っていた(その5)

その4からの続き。

kmuto.hatenablog.com

表紙などのデザイン面について。デザイナーは id:mazco さん。

9/28にデザイン打ち合わせ・10/3にコンセプト確定。多様性、ごった煮、はてなっぽさは出しつつ今までのはてなとはちょっと違うコンセプト、楽しい感じ……とブレインストーミング的に並べていき、「はてラボっぽさを出す方向で決定。「完成度が50%未満のものもあります。」の精神、良き。

サークルカットが『技術季報』用に早くに必要だった覚えがあったので、まずはこれを出さないと!と進行していただいたものの、今の季報ではもう名前でしか掲載していないらしい……申しわけない。サークルカットはWebサイト上で使われるもので、正方形データをアップロードすると丸型に切り抜かれることがわかったので、2案のデザイン案をいただいて、いつものはてなとは少し違って賑やかなタグステッカー風のほうを選んだ。

サークルカット(完成版)

表紙もこのステッカーのイメージをベースに配置していただく。toyaさんが用意してくれたキャッチコピーや、コンテンツからの印象的な文言( id:onishi さんの序文からいろいろ拝借した)、目次などを整理し、要素としてお渡し。

表紙は色パターン違いで3案挙げていただいた。最近のはてならしさを感じる灰地に水色のキリっとした文字、そこにステッカーを乗せることでのわいわい感。絵文字で賑やか推し活。表4(裏表紙)については目次を掲載するとして、シンプルにいくか表紙同様に賑やかにいくか悩んだものの、id:mazco さんのご意見を入れて賑やかのほうでいくことに。

表1〜表4

PPはクリア仕上げ。実物を見るのが楽しみすぎる!

TeXいじり

今回は余白が大きい図も多いので、罫線で囲むようにしている。また、今のreview-jlreqの定義だと図位置がH(Here)固定になってしまうので、オプション指定で変更(tbなど)できるように書き換えた。

% 図囲み
\newcommand*\includeframeboxgraphics[2][]{\bgroup
  \fboxsep=3mm
  \fboxrule=.15mm
  \begin{flushleft}
  \fbox{\hbox to \dimexpr\hsize - 2\fboxsep - 2\fboxrule{\hss
    \includegraphics[#1]{#2}\hss}}%
  \end{flushleft}
\egroup
}

% 図位置指定
\renewenvironment{reviewimage}[1][H]{%
  \begin{figure}[#1]\begin{center}}{\end{center}\end{figure}}

\includeframeboxgraphicsで0.15mmの罫線で3mmパディングのボックスができる。

review-ext.rbでimage_imageindepimageを書き換えてこのマクロを使うようにする。オプションにnoframeがあるかどうかで処理分岐するようにした。

module ReVIEW
  module LATEXBuilderOverride

    ...(ほかの設定)...

    def image_image(id, caption, metric)
      noframe = nil
      if metric =~ /noframe/
        metric.sub!('noframe', '')
        noframe = true
      end

      metrics = parse_metric('latex', metric)
      puts "\\begin{reviewimage}%%#{id}"
      puts macro('label', image_label(id))
      if caption.present?
        @doc_status[:caption] = true
        puts macro('caption', compile_inline(caption))
        puts macro('vspace', '0.4\\Cvs') unless noframe  # フレームがある場合
        @doc_status[:caption] = nil
      end

      cmd = noframe ? 'includegraphics' : 'includeframeboxgraphics'
      if metrics.present?
        puts "\\#{cmd}[#{metrics}]{#{@chapter.image(id).path}}"
      else
        puts "\\#{cmd}{#{@chapter.image(id).path}}"
      end
      puts '\end{reviewimage}'
    end

    def indepimage(lines, id, caption, metric)
      noframe = nil
      if metric =~ /noframe/
        metric.sub!('noframe', '')
        noframe = true
      end
      metrics = parse_metric('latex', metric)

      captionstr = nil
      if caption.present?
        @doc_status[:caption] = true
        captionstr = macro('reviewindepimagecaption',
                           %Q(#{I18n.t('numberless_image')}#{I18n.t('caption_prefix')}#{compile_inline(caption)}))
        # puts macro('vspace', '0.4\\Cvs') unless noframe  # フレームがある場合
        @doc_status[:caption] = nil
      end

      if @chapter.image(id).path
        puts "\\begin{reviewimage}%%#{id}"

        if captionstr
          puts captionstr
        end

        command = noframe ? 'reviewincludegraphics' : 'includeframeboxgraphics'
        if metrics.present?
          puts "\\#{command}[#{metrics}]{#{@chapter.image(id).path}}"
        else
          puts "\\#{command}[width=\\maxwidth]{#{@chapter.image(id).path}}"
        end
      else
        warn "image not bound: #{id}", location: location
        puts '\begin{reviewdummyimage}'
        puts escape("--[[path = #{escape(id)} (#{existence(id)})]]--")
        lines.each do |line|
          puts "\n"
          puts detab(line.rstrip)
        end
      end

      if @chapter.image(id).path
        puts '\end{reviewimage}'
      else
        puts '\end{reviewdummyimage}'
      end
    end

    ...(ほかの設定)...

  end

  class LATEXBuilder
    prepend LATEXBuilderOverride
  end
end