Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tos-kamiya/1379811be0d62da43e62b786c457e120 to your computer and use it in GitHub Desktop.
Save tos-kamiya/1379811be0d62da43e62b786c457e120 to your computer and use it in GitHub Desktop.
latexのソースに毎度書く設定をまとめとく

毎度毎度設定するのでまとめておく。 環境は Ubuntu Gnome 17.04, TexLive 2016


追記(2017.07.10)

ACMの新しいテンプレートに対応する

すべての依存関係を追いきれていませんが、とりあえず次のようにすると、テンプレートに同梱されているmakeでサンプルがコンパイル可能になりました。

sudo apt install texlive-full
sudo apt remove vprerex prerex
sudo apt autoremove

vprerex, prerexは.texに関連付けられてしまう(し特に使わない)ので削除しました。 (これを削除する際には、texlive-fullメタパッケージやtexlive-lang-englishも含めてたくさんのパッケージが削除されますが、特に問題ありません)

めんどくさい人向けのおまけ。上のテンプレートから会議用(sigconf)だけ取り出して、.texソースも短くして固めたもの。このリンクをクリックして「raw」ボタンを押すとダウンロードできます。


以下で、「プリアンプル」とある部分、latexのソースの \documentclass{... の行の後、\begin{document}の行より前のこと。

準備: パッケージマネージャtlmgrのインストール

参考 https://askubuntu.com/questions/485514/how-to-properly-install-and-use-texlive-with-package-manager-in-14-04

sudo apt install xzdec tlmgr
tlmgr init-usertree
sudo tlmgr update --all

日本語フォントの調整

参考 http://qiita.com/tokoro10g/items/a9c74164b35816f2e086

ソースの1行目に次を入れる

\AtBeginDvi{\special{pdf:mapfile ptex-ipa.map}}

ソースコード/verbatimフォントの調整

ソースコードやverbatimのフォントをinconsolataにするには

inconsolataフォントとパッケージをインストールする

sudo apt install fonts-inconsolata
tlmgr install inconsolata

プリアンプルに次を入れる。 (ソースコードの場合には下で説明しているbasicstyle=\footnotesize\ttfamilyに加えて)

\usepackage{inconsolata}

ソースコードに日本語入れたい

https://osdn.net/projects/mytexpert/downloads/26068/jlisting.sty.bz2 から取ってきて、

cd /usr/share/texlive/texmf-dist/tex/latex/listings/
sudo cp ほげほげ/jlisting.sty .
sudo chown root:root jlisting.sty
sudo mktexlsr

ソースのプリアンプルに次を入れる。

\usepackage{listings,jlisting}

ソースコードをシンタックスハイライトするときにぱプリアンプルに(参考 https://www.overleaf.com/9722852dfmrdrphfyqk#/35445773/

\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}

\lstset{ %
  backgroundcolor=\color{white},   % choose the background color
  basicstyle=\footnotesize\ttfamily,        % size of fonts used for the code
  breaklines=true,                 % automatic line breaking only at whitespace
  commentstyle=\color{mygreen},    % comment style
  escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
  keywordstyle=\color{blue},       % keyword style
  stringstyle=\color{mymauve},     % string literal style
}

白黒で印刷する向けには

\lstset{ %
  basicstyle=\footnotesize\ttfamily, % size of fonts used for the code
  breaklines=true,                   % automatic line breaking only at whitespace
  escapeinside={\%*}{*)},            % if you want to add LaTeX within your code
  keywordstyle=\bfseries,            % keyword style
}
\begin{lstlisting}[language=Java]
...
\end{lstlisting}

ソースコード日本語を入れるもう一つのパッケージとしてplistings.styもある。インストール方法はほぼ同じ。

https://github.com/h-kitagawa/plistings

cd /usr/share/texlive/texmf-dist/tex/latex/listings/
sudo cp ほげほげ/plistings.sty .
sudo chown root:root plistings.sty
sudo mktexlsr
\usepackage{listings,plistings}

引用文献が本文中で本当に引用されているか調べる

\usepackage{refcheck}

チェックが終わったらコメントアウトするか削除する。

表のセルを縦に結合する

参考 http://anchoret.seesaa.net/article/79518144.html

tlmgr install multirow
\usepackage{multirow}

結合したいセルの一番上のものは「\multirow{結合する行数}{*}{内容}

結合したい2つ目以降のセルは中身がないセルにしておく。


.latexmkrcに中間ファイル削除のための設定

.latexmkrcに以下の行を書いておく。

@generated_exts = qw(aux brf fls idx ind lof lot out toc acn acr alg glg glo gls ist);

コマンドラインから-cオプション付きでlatexmkを実行する。

latexmk -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment