LaTeXテンプレートと簡単な解説
普段, 勉強ノートやレポート等に使っているLaTeXテンプレートをまとめておきます.
大幅にテンプレートを構成し直しています. (最終更新 2022/12/11)
テンプレートを見る
\documentclass[10pt,titlepage,dvipdfmx]{jsarticle} %------------------------------------------------ % 文書クラス. %------------------------------------------------ \usepackage{algorithm,algpseudocode} % 擬似コード \usepackage{amssymb,amsmath} % 数学記号 \usepackage{amsthm} % 定理環境 \usepackage{bm} % 太文字 \usepackage{clock} % 時計 \usepackage{color} % 文字色の追加 \usepackage[OT2,T1]{fontenc} % キリル文字用 \usepackage{framed} % leftbar環境用 \usepackage{graphicx} % 図の挿入 \usepackage{geometry} % レイアウト設定 \usepackage{indentfirst} % 段落初めをインデントする \usepackage{listings,jvlisting} % コード \usepackage{mathrsfs} % 花文字 \usepackage{mathtools} % showonlyrefs等の便利ツール \usepackage[leftmarker]{mindflow} % アイデアを書く環境 \usepackage{tcolorbox} % 綺麗な定理環境 \usepackage{tikz} % 図の作成 %------------------------------------------------ % パッケージ. %------------------------------------------------ \geometry{margin=15truemm} %------------------------------------------------ % レイアウト設定. %------------------------------------------------ \allowdisplaybreaks[4] \mathtoolsset{showonlyrefs=true} %------------------------------------------------ % 数式に関する設定. % allowdisplaybreaks: align環境において式の途中で改ページを許す. (許容度 1~4) % showonlyrefs: 引用するときのみ式番号を表示. %------------------------------------------------ \tcbuselibrary{breakable,skins,theorems} \definecolor{burgundy}{rgb}{0.5, 0.0, 0.13} \definecolor{charcoal}{rgb}{0.21, 0.27, 0.31} \tcbset{mytheo1/.style={ fonttitle=\gtfamily\sffamily\bfseries\upshape, enhanced, colframe=burgundy, colback=burgundy!2!white, colbacktitle=burgundy, boxrule=0pt, borderline south={2pt}{-2pt}{burgundy}, left*=1zw, right*=1zw, theorem style=standard, breakable,sharp corners, before skip=8pt, after skip=10pt, before upper={\setlength{\parindent}{1zw}}, before lower={\setlength{\parindent}{1zw}} }} \tcbset{mytheo2/.style={ fonttitle=\gtfamily\sffamily\bfseries\upshape, enhanced, colframe=blue!50!black, colback=blue!50!black!2!white, colbacktitle=blue!50!black, boxrule=0pt, borderline south={2pt}{-2pt}{blue!50!black}, left*=1zw, right*=1zw, theorem style=standard, breakable,sharp corners, before skip=8pt, after skip=10pt, before upper={\setlength{\parindent}{1zw}}, before lower={\setlength{\parindent}{1zw}} }} \tcbset{mytheo3/.style={ fonttitle=\gtfamily\sffamily\bfseries\upshape, enhanced, colframe=charcoal, colback=charcoal!2!white, colbacktitle=charcoal, boxrule=0pt, borderline south={2pt}{-2pt}{charcoal}, left*=1zw, right*=1zw, theorem style=standard, breakable,sharp corners, before skip=8pt, after skip=10pt, before upper={\setlength{\parindent}{1zw}}, before lower={\setlength{\parindent}{1zw}} }} \newtcbtheorem[number within=section]{thm}{Theorem}{mytheo1}{thm} % Theorem \newtcbtheorem[use counter from=thm]{prop}{Proposition}{mytheo1}{prop} % Proposition \newtcbtheorem[use counter from=thm]{cor}{Corollary}{mytheo1}{cor} % Corollary \newtcbtheorem[use counter from=thm]{defi}{Definition}{mytheo2}{defi} % Definition \newtcbtheorem[use counter from=thm]{lem}{Lemma}{mytheo1}{lem} % Lemma \newtcbtheorem[use counter from=thm]{ex}{Example}{mytheo3}{ex} % Example \newtcbtheorem[use counter from=thm]{rem}{Remark}{mytheo3}{rem} % Remark %------------------------------------------------ % 定理環境. %------------------------------------------------ \makeatletter \newcommand{\MyAlphabet}[1]{\@tfor\Ch@r:=#1\do{ \expandafter\edef\csname bb\Ch@r\endcsname{\noexpand\mathbb{\Ch@r}} \expandafter\edef\csname cal\Ch@r\endcsname{\noexpand\mathcal{\Ch@r}} \expandafter\edef\csname frak\Ch@r\endcsname{\noexpand\mathfrak{\Ch@r}} \expandafter\edef\csname scr\Ch@r\endcsname{\noexpand\mathscr{\Ch@r}} }} \makeatother \MyAlphabet{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz} \let\Re\relax \DeclareMathOperator{\Re}{Re} \let\Im\relax \DeclareMathOperator{\Im}{Im} \let\epsilon\relax \DeclareMathOperator{\epsilon}{\varepsilon} \makeatletter \newcommand{\MyMathOperators}[1]{\@for\op:=#1\do{ \expandafter\edef\csname\op\endcsname{\noexpand\mathop{\noexpand\mathrm{\op}}\nolimits} }} \makeatother \MyMathOperators{% Ker,% Coker,% Hom,% End,% Aut,% id,% Gal,% ch,% ord,% Spec,% Specm,% Frac,% rank,% corank,% sgn,% alg,% Reg,% Sel,% Cl,% lcm,% gcd,% Ann,% alg,% } %------------------------------------------------ % 新しい数学演算子の定義. % 参考: % https://mathlandscape.com/declaremathoperator/ %------------------------------------------------ \renewcommand{\bar}[1]{\overline{#1}} \renewcommand{\tilde}[1]{\widetilde{#1}} \renewcommand{\hat}[1]{\widehat{#1}} \newcommand{\red}[1]{\textcolor{red}{#1}} % コメント用 \newcommand{\blue}[1]{\textcolor{blue}{#1}} % コメント用 \newenvironment{btl}{\begin{leftbar}\color{gray}}{\color{black}\end{leftbar}} % 行間(between the lines)埋め \let\|\relax \newcommand{\|}{\verb|} % 入力した文字をそのまま出力 %------------------------------------------------ % 新しい関数や補助関数の定義. %------------------------------------------------ \renewcommand{\mindflowTextFont}{\normalfont\footnotesize\sffamily\itshape} % mindflow環境のテキストフォント変更 \renewcommand{\mindflowNumFont}{\normalfont\footnotesize\sffamily} % mindflow環境の数字フォント変更 \renewcommand{\mindflowLeft}{\hspace{1em}\(\succ\)} % mindflow環境の左側の設定 \renewcommand{\mindflowRight}{\(\prec\)} % mindflow環境の右側の設定 \setlength{\mindflowLineHeight}{1pt} % mindflow環境の行間調整 %------------------------------------------------ % mindflow環境. %------------------------------------------------ \DeclarePairedDelimiter{\skakko}{\lparen}{\rparen} % 括弧( ) \DeclarePairedDelimiter{\mkakko}{\lbrace}{\rbrace} % 括弧{ } \DeclarePairedDelimiter{\lkakko}{\lbrack}{\rbrack} % 括弧[ ] \DeclarePairedDelimiter{\gkakko}{\langle}{\rangle} % 括弧< > \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} % 絶対値| | \DeclarePairedDelimiterX{\set}[2]{\lbrace}{\rbrace}{#1\,\delimsize\vert\,#2} % 集合{ } %------------------------------------------------ % 括弧の大きさ等を自動的に調整. % 参考: % https://mathlandscape.com/declarepaireddelimiter/ %------------------------------------------------ \DeclareSymbolFont{cyrletters}{OT2}{wncyr}{m}{n} \DeclareMathSymbol{\Sha}{\mathalpha}{cyrletters}{"58} %------------------------------------------------ % Shaの出力. %------------------------------------------------ \renewcommand{\theenumi}{\roman{enumi}} % 箇条書きの第一階層の番号の付け方をi,ii,iii,...にする \renewcommand{\labelenumi}{(\theenumi)} \renewcommand{\theenumii}{\theenumi-\alph{enumii}} % 箇条書きの第二階層の番号の付け方をi-i,i-ii,i-iii,...にする \renewcommand{\labelenumii}{(\theenumii)} %------------------------------------------------ % enumerate環境の見出し変更. % 参考: % https://mathlandscape.com/latex-enum/ %------------------------------------------------ \makeatletter \renewcommand{\ALG@name}{Algorithm} \makeatother \algrenewcommand{\algorithmicrequire}{\textbf{Input:}} \algrenewcommand{\algorithmicensure}{\textbf{Output:}} \algrenewcommand{\algorithmicthen}{\textbf{:}} % if then -> if : \algrenewcommand{\algorithmicelse}{\textbf{else:}} % else -> else : \algrenewcommand{\algorithmicdo}{\textbf{:}} % while do -> while : \algnewcommand{\Continue}{\textbf{continue}} \algnewcommand{\Break}{\textbf{break}} %------------------------------------------------ % 擬似コード. %------------------------------------------------ \lstnewenvironment{sage}[1][]{ \lstset{ language=Python, basicstyle={\ttfamily}, % 全体のフォント identifierstyle={\small}, % キーワードでないもののフォント commentstyle={\smallitshape}, % コメントのフォント stringstyle={\small}, % 文字のフォント keywordstyle={\small\bfseries}, % ndkeywordstyle={\small}, % stringstyle={\small\ttfamily}, numberstyle={\scriptsize}, numbers=left, % 左に行番号を表示 stepnumber=1, % 数字がどれだけずつ増えるか numbersep=1zw, % 数字とコードの間のスペース xleftmargin=3zw, % 左側のスペース xrightmargin=0zw, % 右側のスペース breaklines=true, % 長いlineは折り返す frame={lines}, % 枠の種類 columns=[l]{fullflexible}, lineskip=-0.5ex }}{} %------------------------------------------------ % プログラムコード. %------------------------------------------------ \usepackage{hyperref} \usepackage{pxjahyper} \hypersetup{% colorlinks=true, % リンクのテキストに色を付ける linkcolor=blue, % \refによる標準リンクのテキストの色 citecolor=blue, % 参考文献リンクのテキストの色 urlcolor=blue, % URLリンクのテキストの色 } %------------------------------------------------ % 引用する際のリンク付け. % こいつは色々と悪さをするので, なるべく後半に読み込む. % pxjahyper: PDF機能のしおり機能の日本語文字化けを防ぐ (hyperrefの後に記述する) %------------------------------------------------ \def\MyMailAddress{メールアドレス} \title{タイトル} \author{氏名 \thanks{mail: \href{\MyMailAddress}{\texttt{\MyMailAddress}}}} \date{最終更新: \today \texthours 時 \textminutes 分 \clocktime} %------------------------------------------------ % タイトル設定. %------------------------------------------------
文書クラス
\documentclass[10pt,titlepage,dvipdfmx]{jsarticle}
プリアンブルに必ず一つだけ記述するもの. 書き方は
である. スタイルファイル名は例えば以下のような種類がある.
スタイルファイル名 | 備考 |
---|---|
jsarticle |
和文の論文執筆用. |
jsbook |
和文の本執筆用. |
article |
欧文の論文執筆用. |
book |
欧文の本執筆用. |
report |
欧文の報告書執筆用. 和文の報告書はない. |
beamer |
パワーポイントのようなスライドを作成できる. |
amsart |
米国数学会(American Mathmatical Society)が公開しているスタイルファイル. |
以下では, 特に使用することが多いであろうスタイルファイルjsarticle
で使用可能なオプションを, 主要なものをいくつかまとめる.
ただし, jsarticle
以外のスタイルファイルでも使用可能なオプションもあることに注意.
titlepage
: タイトルを独立したページを作成する.@pt
: 文字サイズ@ptにする. (@=10(defalut), 11, 12等)@paper
: 用紙サイズを@にする. (@=a4(default),a5, b4, b5)@column
: 文章を@段組にする. (@=one(default), two)@eqno
: 数式番号を@寄せ出力にする. (@=l(default), r)landscape
: 用紙の向きを横長にする.titlepage
: タイトルのみのページを作成する.slide
: 出力をスライド形式にする. beamerのシンプルバージョン.draft
,final
: draftを指定すると, 警告「overfull \hbox」が発生している箇所の右端に5ptの罫線を引く.
パッケージ
\usepackage{algorithm,algpseudocode} % 擬似コード \usepackage{amssymb,amsmath} % 数学記号 \usepackage{amsthm} % 定理環境 \usepackage{bm} % 太文字 \usepackage{clock} % 時計 \usepackage{color} % 文字色の追加 \usepackage[OT2,T1]{fontenc} % キリル文字用 \usepackage{framed} % leftbar環境用 \usepackage{graphicx} % 図の挿入 \usepackage{geometry} % レイアウト設定 \usepackage{indentfirst} % 段落初めをインデントする \usepackage{listings,jvlisting} % コード \usepackage{mathrsfs} % 花文字 \usepackage{mathtools} % showonlyrefs等の便利ツール \usepackage[leftmarker]{mindflow} % アイデアを書く環境 \usepackage{tcolorbox} % 綺麗な定理環境 \usepackage{tikz} % 図の作成
以下で記述しているマクロに必要となるパッケージ. (このようにパッケージだけ先に読み込むような書き方はあまり推奨されないと思います. 自己責任でお使いください.)
レイアウト設定
\geometry{margin=15truemm}
本テンプレートは私的な勉強ノート用なので, ページいっぱいに使えるように空白の指定をしている.
数式に関する設定
\allowdisplaybreaks[4]
複数行に渡る数式中の改ページを行うための設定. 通常, 何行にも渡る数式を書いていってページの最下部まで辿り着くと 勝手に新しいページの最上部からその数式を出力し始めてしまう. そもそも正式な文書ではそのような何行にも渡る数式を書くのは避けたいかもしれないが, 少なくとも個人のノートレベルでは構わないので, この設定をしておく. 数字「4」は, 改ページする許容度を表す数値であり, 整数値1~4を選択できる. 「1」とすれば, なるべく数式中の改ページをしないような設定になり, 「4」とすれば, 強制的に改ページをする設定となる.
\mathtoolsset{showonlyrefs=true}
個人的にこのテンプレートの中で一番便利だと思っているもの.
mathtools
パッケージに含まれている設定である.
参照したい数式は\begin{align}hoge\end{align}
と書いて,
参照したくない数式は, 数式番号を付けないように
\begin{align*}hoge\end{align*}
と書くのは, かなりめんどくさい.
そこで, showonlyrefs
を設定することで, 全ての数式環境を\begin{align}hoge\end{align}
と書けばよくなる.
「*
」が付いてないが, 出力には数式番号が振られなくなる.
しかしその数式にラベルを付けて参照することで, 数式番号が付けられる.
これを用いれば, 「やっぱりこの数式を参照しなくていいや」となった場合に「*
」をわざわざ外さなくてよい.
定理環境
\tcbuselibrary{breakable,skins,theorems} \definecolor{burgundy}{rgb}{0.5, 0.0, 0.13} \definecolor{charcoal}{rgb}{0.21, 0.27, 0.31} \tcbset{mytheo1/.style={ fonttitle=\gtfamily\sffamily\bfseries\upshape, enhanced, colframe=burgundy, colback=burgundy!2!white, colbacktitle=burgundy, boxrule=0pt, borderline south={2pt}{-2pt}{burgundy}, left*=1zw, right*=1zw, theorem style=standard, breakable,sharp corners, before skip=8pt, after skip=10pt, before upper={\setlength{\parindent}{1zw}}, before lower={\setlength{\parindent}{1zw}} }} \tcbset{mytheo2/.style={ fonttitle=\gtfamily\sffamily\bfseries\upshape, enhanced, colframe=blue!50!black, colback=blue!50!black!2!white, colbacktitle=blue!50!black, boxrule=0pt, borderline south={2pt}{-2pt}{blue!50!black}, left*=1zw, right*=1zw, theorem style=standard, breakable,sharp corners, before skip=8pt, after skip=10pt, before upper={\setlength{\parindent}{1zw}}, before lower={\setlength{\parindent}{1zw}} }} \tcbset{mytheo3/.style={ fonttitle=\gtfamily\sffamily\bfseries\upshape, enhanced, colframe=charcoal, colback=charcoal!2!white, colbacktitle=charcoal, boxrule=0pt, borderline south={2pt}{-2pt}{charcoal}, left*=1zw, right*=1zw, theorem style=standard, breakable,sharp corners, before skip=8pt, after skip=10pt, before upper={\setlength{\parindent}{1zw}}, before lower={\setlength{\parindent}{1zw}} }} \newtcbtheorem[number within=section]{thm}{Theorem}{mytheo1}{thm} % Theorem \newtcbtheorem[use counter from=thm]{prop}{Proposition}{mytheo1}{prop} % Proposition \newtcbtheorem[use counter from=thm]{cor}{Corollary}{mytheo1}{cor} % Corollary \newtcbtheorem[use counter from=thm]{defi}{Definition}{mytheo2}{defi} % Definition \newtcbtheorem[use counter from=thm]{lem}{Lemma}{mytheo1}{lem} % Lemma \newtcbtheorem[use counter from=thm]{ex}{Example}{mytheo3}{ex} % Example \newtcbtheorem[use counter from=thm]{rem}{Remark}{mytheo3}{rem} % Remark
tcolorbox
環境を用いた定理環境の設定.
かなり自由度が高い環境のため, 公式ドキュメントは非常に量が多く, 使いこなすには時間がかかる.
そのためここでは説明を省略する.
参考文献
数学演算子
\makeatletter \newcommand{\MyAlphabet}[1]{\@tfor\Ch@r:=#1\do{ \expandafter\edef\csname bb\Ch@r\endcsname{\noexpand\mathbb{\Ch@r}} \expandafter\edef\csname cal\Ch@r\endcsname{\noexpand\mathcal{\Ch@r}} \expandafter\edef\csname frak\Ch@r\endcsname{\noexpand\mathfrak{\Ch@r}} \expandafter\edef\csname scr\Ch@r\endcsname{\noexpand\mathscr{\Ch@r}} }} \makeatother \MyAlphabet{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}
記述しているのは
を簡単に書くマクロである.
これを書くことで, \MyAlphabet
に登録しているアルファベットに関して,
例えば\mathbb{C}
を\bbC
, \mathcal{L}
を\calL
のように書けるようになる.
\makeatletter \newcommand{\MyMathOperators}[1]{\@for\op:=#1\do{ \expandafter\edef\csname\op\endcsname{\noexpand\mathop{\noexpand\mathrm{\op}}\nolimits} }} \makeatother \MyMathOperators{% Ker,% Coker,% Hom,% End,% Aut,% id,% Gal,% ch,% ord,% Spec,% Specm,% Frac,% rank,% corank,% sgn,% alg,% Reg,% Sel,% Cl,% lcm,% gcd,% Ann,% alg,% }
さらに \MyMathOperators
に登録しているアルファベットに関して,
例えば\mathop{Ker} f
を\Ker f
, \mathop{Spec} R
を\Spec R
のように書けるようになる.
間違っても, Ker f
や\textrm{Ker} f
のように書いてはいけない.
このように書くと「Kerf」と斜体になってしまったり「Kerf」のように文字感覚が狭くなったりして見栄えが悪い.
(そもそも「Kerf」は文字「K」「 e」「 r」「 f」の積として認識されてしまう)
\let\Re\relax \DeclareMathOperator{\Re}{Re} \let\Im\relax \DeclareMathOperator{\Im}{Im} \let\epsilon\relax
複素数の実部を表す\Re
と虚部を表す\Im
は既に登録されている.
しかし実際に出力される記号は, 現在の慣習とは異なる記号であるように思える.
したがって一度\let\Re\relax
のように書いて, 未定義語に変更する.
その後, 数学作用素として\DeclareMathOperators{\Re}{Re}
と定義する.
(定義を削除するマクロを\MyMathOperators
の前に書いて, Re
とIm
を\MyMathOperators
の中に入れてもよい)
参考文献
新しい関数や補助関数
\renewcommand{\bar}[1]{\overline{#1}} \renewcommand{\tilde}[1]{\widetilde{#1}} \renewcommand{\hat}[1]{\widehat{#1}} \renewcommand{\epsilon}{\varepsilon}
指標の共役を書く際の\bar{\chi}
,
パラメータ付き楕円曲線のreductionを書く際の\tilde{E_{D}}
Pontryagin双対を書く際の\hat{\bbQ_p/\bbZ_p}
等,
適切なサイズの記号の装飾を使う場面が(少なくとも私は)ほとんどない.
したがって初めから\overline
, \widetilde
, \widehat
で再定義しておく.
また, \epsilon
を使ったことも一度もなく, \varepsilon
を使うことがほとんどなので, このように設定しておく.
\newcommand{\red}[1]{\textcolor{red}{#1}} % コメント用 \newcommand{\blue}[1]{\textcolor{blue}{#1}} % コメント用 \newenvironment{btl}{\begin{leftbar}\color{gray}}{\color{black}\end{leftbar}} % 行間(between the lines)埋め \let\|\relax \newcommand{\|}{\verb|} % 入力した文字をそのまま出力
最初の二つは, 論文の添削や, 後で見返したい部分を強調するため等に使用するマクロ.
\red{後で証明見返す.}
みたいな感じで使うことが多い.
三つ目は, 行間を埋める際に用いるマクロ.
証明をTeXでまとめているときに, 行間を全て埋めて書くと全体の見通しが悪くなる場合がある.
そのようなときに, 行間部分だけ\begin{hosoku}行間\end{hosoku}
と書くことで全体の流れを断ち切らないような文章表現ができる.
四つ目は, 何かしらのコマンド名をそのまま出力するためのマクロ.
\|\begin{align} e^{i\pi}+1=0 \end{align}|
のように使う.
mindflow環境
\renewcommand{\mindflowTextFont}{\normalfont\footnotesize\sffamily\itshape} % mindflow環境のテキストフォント変更 \renewcommand{\mindflowNumFont}{\normalfont\footnotesize\sffamily} % mindflow環境の数字フォント変更 \renewcommand{\mindflowLeft}{\hspace{1em}\(\succ\)} % mindflow環境の左側の設定 \renewcommand{\mindflowRight}{\(\prec\)} % mindflow環境の右側の設定 \setlength{\mindflowLineHeight}{1pt} % mindflow環境の行間調整
mindflow
環境と言って, 名前の通り本文とは別に, 自身の考え等をメモしておくための環境.
参考文献
カッコ
\DeclarePairedDelimiter{\skakko}{\lparen}{\rparen} % 括弧( ) \DeclarePairedDelimiter{\mkakko}{\lbrace}{\rbrace} % 括弧{ } \DeclarePairedDelimiter{\lkakko}{\lbrack}{\rbrack} % 括弧[ ] \DeclarePairedDelimiter{\gkakko}{\langle}{\rangle} % 括弧< > \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} % 絶対値| | \DeclarePairedDelimiterX{\set}[2]{\lbrace}{\rbrace}{#1\,\delimsize\vert\,#2} % 集合{ }
mathtools
パッケージの便利なマクロ.
括弧の大きさを中の式に合わせて変更するには\left( 式 \right)
のように記述するが,
このマクロを書いておくと, \skakko*{式}
と書くだけで括弧の大きさを調節してくれる.
ちなみにskakko
は「small kakko」の略である.
あとgkakko
は生成元を記述するときに使うことが多いので
「generator kakko」の略として命名している.
絶対他に最適な命名があるはず. いい案があれば教えてください.
また, 集合を\mkakko*{元\mid 条件}
のように書くと, 中身によっては縦線\mid
が適切な大きさになってくれない.
そこで上のように\set
を定義すると, \set{元}{条件}
と書くことで縦線\mid
が自動的に挿入され, 適切な大きさで表示してくれる.
参考文献
キリル文字
\DeclareSymbolFont{cyrletters}{OT2}{wncyr}{m}{n} \DeclareMathSymbol{\Sha}{\mathalpha}{cyrletters}{"58}
Tate-Shafarevich群を記述するための設定. キリル文字のShaはデフォルトのフォントに入っていないので, 改めて追加する必要がある.
箇条書き
\renewcommand{\theenumi}{\roman{enumi}} \renewcommand{\labelenumi}{(\theenumi)} \renewcommand{\theenumii}{\theenumi-\alph{enumii}} \renewcommand{\labelenumii}{(\theenumii)}
箇条書きの項目番号の変更.
参考文献
擬似コード
\makeatletter \renewcommand{\ALG@name}{Algorithm} \makeatother \algrenewcommand{\algorithmicrequire}{\textbf{Input:}} \algrenewcommand{\algorithmicensure}{\textbf{Output:}} \algrenewcommand{\algorithmicthen}{\textbf{:}} % if then -> if : \algrenewcommand{\algorithmicelse}{\textbf{else:}} % else -> else : \algrenewcommand{\algorithmicdo}{\textbf{:}} % while do -> while : \algnewcommand{\Continue}{\textbf{continue}} \algnewcommand{\Break}{\textbf{break}}
アルゴリズムを記述するための設定. まだ納得いっていない設定なので後に修正.
プログラムコード
\lstnewenvironment{sage}[1][]{ \lstset{ language=Python, basicstyle={\ttfamily}, % 全体のフォント identifierstyle={\small}, % キーワードでないもののフォント commentstyle={\smallitshape}, % コメントのフォント stringstyle={\small}, % 文字のフォント keywordstyle={\small\bfseries}, % ndkeywordstyle={\small}, % stringstyle={\small\ttfamily}, numberstyle={\scriptsize}, numbers=left, % 左に行番号を表示 stepnumber=1, % 数字がどれだけずつ増えるか numbersep=1zw, % 数字とコードの間のスペース xleftmargin=3zw, % 左側のスペース xrightmargin=0zw, % 右側のスペース breaklines=true, % 長いlineは折り返す frame={lines}, % 枠の種類 columns=[l]{fullflexible}, lineskip=-0.5ex }}{}
このブログの筆者は, sageでコードを書くことが多いので, それに合わせた設定を行なっている. いくつか何の設定をしているか不明なところがあるので後に修正.
参考文献
リンク付け
\usepackage{hyperref} \usepackage{pxjahyper} \hypersetup{% colorlinks=true, % リンクのテキストに色を付ける linkcolor=blue, % \refによる標準リンクのテキストの色 citecolor=blue, % 参考文献リンクのテキストの色 urlcolor=blue, % URLリンクのテキストの色 }
参考文献の引用であったり, 式の参照を行った際にリンクを付けるための設定. そのリンクの文字色や囲みの色等を変更することができる. ただし, このパッケージは他のパッケージに色々と悪さをするので, なるべくプリアンブルの後半に読み込む.