1
5

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 3 years have passed since last update.

pandocでmarkdown→LaTeX変換するとき、hyperlinkを出力しない

Posted at

pandocを使えば、いちいち\subsubsection{小見出し}とか明らかに日本語向けでないtexの悪しき記法を使うことなくmarkdownで色んなものが書けてチョー快適であるが、pandocくんは結構余計なおせっかいをしてくる。

問題

kinotake.md

# 背景

## きのたけ戦争

日本人は元来きのこ軍とたけのこ軍に分かれ、現在もなおどちらが優れているなどと血で血を洗う争いが続けられている。これがきのこたけのこ戦争である。なおこの戦争の黒幕が明治であることは言うまでもない。

こんな文書をpandoc kinotake.md -o kinotake.texすると、

\hypertarget{ux80ccux666f}{%
\section{背景}\label{ux80ccux666f}}

\hypertarget{ux304dux306eux305fux3051ux6226ux4e89}{%
\subsection{きのたけ戦争}\label{ux304dux306eux305fux3051ux6226ux4e89}}

日本人は元来きのこ軍とたけのこ軍に分かれ、現在もなおどちらが優れているなどと血で血を洗う争いが続けられている。これがきのこたけのこ戦争である。なおこの戦争の黒幕が明治であることは言うまでもない。

こんなふうに変換してくる。なんかゴテゴテしてない?

\hypertarget ってなんだ?

こちらを参照。生成されるpdfファイルにページ内リンクやら何やらをつけてくれるプラグインらしい。
便利だが、いらんこともある。何より日本語をunicodeに変換してつけてるせいで汚い。

解決法

StackOverflowに解決策が載っていた。
pandoc -r markdown-auto_identifiersすればいいらしい。実際にやってみた。

\section{背景}

\subsection{きのたけ戦争}

日本人は元来きのこ軍とたけのこ軍に分かれ、現在もなおどちらが優れているなどと血で血を洗う争いが続けられている。これがきのこたけのこ戦争である。なおこの戦争の黒幕が明治であることは言うまでもない。

すっきりした。解決。
長いのでaliasとかに登録しておくと便利かもしれない。

1
5
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
1
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?