0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Re:VIEW] minted を使ったコードブロックで自動改行されない場合の解消方法

Posted at

上記の記事を参考に、review-ext.rb を設定したところ、listnum などのコードブロックにおいて長い行がブロックをはみ出してしまう。この解消に少しハマったのでメモ。

原因

minted パッケージの breaklines オプションが効いていないことが原因。

対処

以下の2通りの方法で解消できる。

言語ごとに自動改行を有効化する方法

review-custom.sty ファイルに以下を追記する。

% for user-defined macro
\usepackage{minted}
\usemintedstyle{solarized-light}

+ \setminted[python]{breaklines=true}

他の minted のオプションも同様にここで指定できる。
これは上記のドキュメントにも記載があったが、breaklines オプションが自動改行を司っていることに気付くのにすこしかかった。

全てを対象に自動改行を有効化する方法

これは review-ext.rb を編集する方法。ドキュメントの通りに設定していれば、common_minted_code() の中に以下の記述がある。

      args = ''
      if lineno
        args = "linenos=true,firstnumber=#{lineno}"
      end
      puts %Q(\\begin{minted}[#{args}]{#{lang}})

これを以下のように書き換える。

-     args = ''
+     args = 'breaklines=true'
      if lineno
-        args = "linenos=true,firstnumber=#{lineno}"
+        args = "linenos=true,firstnumber=#{lineno},breaklines=true"
      end
      puts %Q(\\begin{minted}[#{args}]{#{lang}})

これで minted を使ったコードブロックでも自動改行が有効化される。

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?