Re:VIEWで以下のような枠囲いを追加したい!ということで、tcolorboxを利用したascolorboxを使って出力できるようにしました。
参考
tcolorboxによる装飾表現(TeXユーザの集い2015)
こちらで発表されたascolorbox.styを利用します。
色々とブログでも説明されているため、詳細なオプション等はこちらを参考にして頂ければと思います。
使えるようになる枠囲い
今回はascolorbox マニュアルで説明されている、以下の3つの枠囲いを使えるようにします。
※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.
//}
完成!
備考
review-ext.rbの書き方も大分わかってきた!
本当は一つのコマンドで、ascolorboxの中をすべて表現できるようにオプション選択したかったけど、引数がちょいちょい違うのでやめました