LoginSignup
4
4

More than 5 years have passed since last update.

Re:VIEWで装飾された枠囲い文章を追加する

Posted at

Re:VIEWで以下のような枠囲いを追加したい!ということで、tcolorboxを利用したascolorboxを使って出力できるようにしました。

スクリーンショット 2016-03-04 12.12.04.png

参考

tcolorboxによる装飾表現(TeXユーザの集い2015)

こちらで発表されたascolorbox.styを利用します。

tcolorboxの基本 - 物理とTeXに関する話題

色々とブログでも説明されているため、詳細なオプション等はこちらを参考にして頂ければと思います。

使えるようになる枠囲い

今回はascolorbox マニュアルで説明されている、以下の3つの枠囲いを使えるようにします。

  • memo
    スクリーンショット 2016-03-04 12.12.04.png
  • practice
    スクリーンショット 2016-03-04 12.23.40.png
  • subtitlebox
    スクリーンショット 2016-03-04 12.24.08.png

※memo/practice/subtitleboxはRe:VIEW中で利用する時の名前であり、任意で変更して下さい

記述方法

以下のように記述すると出力されるようにしたいと思います

% 引数のcolorやoptionは任意 : ascolorboxマニュアル参照

% memo
//memo[メモタイトル][color][option]{
 枠内メッセージ
//}

//practice[練習問題のタイトル][option]{
 枠内メッセージ
//}

@<subtitlebox>{サブタイトル}

インストール

ascolorbox.styの取得

あざらしの保管庫にある、ascolorbox.styをダウンロードし、styフォルダにコピーして下さい。

 ❯ tree .                                                                                                                                                     [12:18:30]
.
├── catalog.yml
├── config.yml
├── review-ext.rb
└── sty
    ├── ascolorbox.sty
    └── reviewmacro.sty

styの変更

自身の使っている*.styファイルに以下を追記し、ascolorboxを読み込むように修正して下さい

\usepackage[most]{tcolorbox}
\usepackage{ascolorbox}

必要なモジュールインストール

ascolorboxはvarwidthを使っているので、入ってない場合はインストールしましょう。(basictexを使ってる私の場合はデフォルトで入ってなかった)

sudo tlmgr install varwidth

review-ext.rbの修正

review-ext.rbに以下を追加し、Re:VIEW文書に記述できるように拡張します。

ReVIEW::Compiler.definline :subtitlebox
ReVIEW::Compiler.defblock :practice, 1..2
ReVIEW::Compiler.defblock :memo, 1..3

module ReVIEW
    def inline_subtitlebox(str)
      "\\ascboxA{#{str}}"
    end

    def practice(lines, title, option = "")
      blank
      puts "\\begin{practicebox}{#{title}}[#{option}]"
      lines.each do |line|
        puts detab(line)
      end
      puts "\\end{practicebox}"
      blank
    end

    def memo(lines, title, color = "black", option = "")
      blank
      puts "\\begin{ascolorbox3}{#{title}}[#{color}][#{option}]"
      lines.each do |line|
        puts detab(line)
      end
      puts "\\end{ascolorbox3}"
      blank
    end

  end
end

実際に書いてみる

@<subtitlebox>{サブタイトルボックスヒア}

//practice[練習問題のタイトル]{
  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
//}

//memo[メモタイトル]{
  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
//}

//memo[メモタイトル][orange]{
  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
//}

完成!

スクリーンショット 2016-03-04 12.35.57.png

備考

review-ext.rbの書き方も大分わかってきた!

本当は一つのコマンドで、ascolorboxの中をすべて表現できるようにオプション選択したかったけど、引数がちょいちょい違うのでやめました

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4