僕が普段よく使うLaTeXのプリアンブル

僕が普段よく使っているLaTeX文書の書式を載せておきます。ご自由に参考になさってください!

想定:
・本の証明の行間を埋めてまとめたノートを作りたい!
・膨大な文書をできるだけ手軽に効率よく編集したい!

特徴:
・LuaLaTeX & jlreq を使用します。
Macからヒラギノ書体を表示させます。(luatexja-preset)
・定理環境を見やすくデザインしてあります。(tcolorbox)
・カラーユニバーサルデザインにも対応。(definecolor)
・膨大な文書を効率よく管理できます。(docmute, input)
・まとまった1つのPDFと,章ごと節ごとのPDFを,
    使い分けて出力することができます。
・100ページ超の勉強用ノートの作成に向いています。

書式見本:

以下,コードを載せます。

(1) メインのファイル
main.tex

%----------
\title{***ノート}
\author{******}
\date{2023年 *月 *日 作成}
%----------
\documentclass[
 book,
 head_space=20mm,
 foot_space=20mm,
 gutter=10mm,
 line_length=190mm
]{jlreq}
%----------
\input 0_preamble.tex
\usepackage{docmute} %ファイル分割
%----------
\begin{document}


\maketitle %タイトル
\tableofcontents %目次


\clearpage


本文あいうえおかきくけこ


\end{document}


後述するように,
ファイル分割を効率よく実現するために
main.tex には \usepackage{docmute}
を使用しています。




(2) 分割したプリアンブルファイル
preamble.tex



%----------
%LuaLaTeXで実行する!!
% \documentclass[
%  book,
%  head_space=20mm,
%  foot_space=20mm,
%  gutter=10mm,
%  line_length=190mm
% ]{jlreq}
%----------
%----------
%%%%% bookの設定
 \NewPageStyle{mystyle}{
 yoko,
 running_head_position={top-center},
 nombre_position={top-fore-edge},
 odd_running_head={_section},
 even_running_head={_chapter}
 }
 \pagestyle{mystyle}
%----------
%----------
\usepackage{luatexja}
%==========
%----------
%目次のレイアウト調整
\makeatletter
\def\l@part{%
  % |\@dottedtocline|の代わりに独自の命令を使う
  \my@dottedtocline
  {0} %見出しのレベル
  {0.8\baselineskip} %前の行とのアキ
  {0pt} %字下げ
  {6\zw} %ラベル(「第1章」等)の幅
%   {\sffamily\bfseries\gtfamily\large} %フォント
  {\large} %フォント
%   {\rmfamily} %フォント
}
\def\l@chapter{%
  % |\@dottedtocline|の代わりに独自の命令を使う
  \my@dottedtocline
  {1} %見出しのレベル
  {0\baselineskip} %前の行とのアキ
  {0pt} %字下げ
  {6\zw} %ラベル(「第1章」等)の幅
  {\rmfamily} %フォント
}
\def\l@section{%
  % |\@dottedtocline|の代わりに独自の命令を使う
  \my@dottedtocline
    {2} %見出しのレベル
    {0\baselineskip} %前の行とのアキ
    {0pt} %字下げ
    {6\zw} %ラベル(「第1章」等)の幅
    {\rmfamily} %フォント
}
\def\l@subsection{%
  % |\@dottedtocline|の代わりに独自の命令を使う
  \my@dottedtocline
    {3} %見出しのレベル
    {0\baselineskip} %前の行とのアキ
    {0pt} %字下げ
    {6\zw} %ラベル(「第1章」等)の幅
    {\rmfamily} %フォント
}
\def\l@subsubsection{%
  % |\@dottedtocline|の代わりに独自の命令を使う
  \my@dottedtocline
    {4} %見出しのレベル
    {0\baselineskip} %前の行とのアキ
    {0pt} %字下げ
    {6\zw} %ラベル(「第1章」等)の幅
    {\rmfamily} %フォント
}
% jlreqの|\@dottedtocline|を元に独自の命令を定義
\def\my@dottedtocline#1#2#3#4#5#6#7{%
  \jlreq@set@top@contents{#1}%
  \ifnum #1>\c@tocdepth \else
    \vskip #2\relax
    {\leftskip #3\relax \rightskip \@tocrmarg \parfillskip -\rightskip
    \parindent #3\relax\@afterindenttrue
    \interlinepenalty\@M
    \leavevmode
    \@lnumwidth #4\relax
    \@tempcnta=#1\relax
    \advance\@tempcnta by -\jlreq@top@contents
    \@tempdima=1\jlreq@mol
    \multiply \@tempdima by \@tempcnta
    \advance\leftskip \@lnumwidth \hbox{}\hskip -\leftskip
    \advance\leftskip\@tempdima
    {#5#6}\nobreak
    \leaders\hbox{$\m@th\mkern \@dotsep mu$\null\inhibitglue\inhibitglue\null$\m@th\mkern \@dotsep mu$}%
    \hfill\nobreak
    \hb@xt@\@pnumwidth{\hss\normalfont\normalcolor #7}%
    \par}%
  \fi}
\makeatother
%----------
%==========
% パッケージ集
%==========
%数式フォント
%\usepackage{lxfonts}
\usepackage{bm}%太字のベクトルを表示
\usepackage{mathrsfs}%アルファベット筆記書体など
%日本語フォント
\usepackage{luatexja-fontspec}
\usepackage[hiragino-pro]{luatexja-preset}
%\setmainjfont{UDDigiKyokashoNP-R}[BoldFont={UDDigiKyokashoNP-B}]
%欧文フォント
%\usepackage[LGR,LGRx,T2A,T1,OT1]{fontenc}
\usepackage[LGR,T2A,T1]{fontenc}
% \usepackage[utf8x]{inputenc}
\usepackage{tgheros}
\usepackage{lmodern}
%\usepackage{mathpazo}
%ギリシャ語フォント
\usepackage[polutonikogreek,greek,english,japanese]{babel}
% ¥usepackage[boldLipsian,10pt,GlyphNames]{teubner}
\usepackage{teubner}
\usepackage{substitutefont}
\substitutefont{LGR}{\rmdefault}{porson}
% ¥substitutefont{LGR}{¥rmdefault}{neohellenic}
% 例 ¥textgreek{paide'uw} ギリシャ文字で表示
% 例 ¥greeknumeral{2022} ギリシャ数字で表示
%---------
\usepackage{luatexja-otf}
\usepackage{luatexja-ruby}
\usepackage[unicode,hidelinks,pdfusetitle]{hyperref}
%---------
%\languageattribute{greek}{polutoniko}
%----------
\usepackage{graphicx} %画像の挿入
\usepackage{wrapfig} %図の回り込み
\usepackage{framed,color} %枠付き文書
\definecolor{shadecolor}{gray}{0.85}
% \begin{oframed} 文 \end{oframed}
% \begin{shaded} 文 \end{shaded}
%----------
\usepackage{setspace}
%----------
\usepackage{colortbl}
\usepackage{tikz}
\usepackage{tikz-cd} %可換図式
\usepackage{tikz-3dplot}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
%---------
\usepackage{ascmac}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amscd}
% \usepackage{pb-diagram} %可換図式
\usepackage{fancybox}
\usepackage{enumerate}
\usepackage{ulem} %下線
%---------
\usepackage{lipsum} %ダミーテキスト 
% 例: \lipsum[1-5]
%---------
%丸囲い
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
%---------
\renewcommand{\textgt}[1]{\textsf{\textbf{#1}}}
%---------
\usepackage{multicol} % n段組み 
%\begin{multicols}{段数} 文章 \end{multicols}
%----------
\usepackage{vwcol}
% \begin{vwcol}[widths={0.6,0.4},rule=0.5pt] 
% 文章
% \end{vwcol}
%----------
\usepackage{physics} %便利なパッケージ
% \qty() , \qty|| ,\norm{} など ...... カッコ
% \vb{} ...... 太字のベクトル
% 数式数式  \qq{テキスト}  数式数式
% \dd[指数]{x} ...... dx
% \dv{x} ............ d/dx
% \pdv{x} ........... ∂/∂x
% \dv{f}{x} ......... df/dx
% \pdv{f}{x} ........ ∂f/∂x
% \mqty(a&b\\c&d) , \mqty|| 行列・行列式
% \mqty{\imat{n}} ...... 単位行列
% \mqty{\dmat[0]{n}} ... 対角行列
% \mqty{\xmat*{a}{m}{n}} ... {a_mn}行列
\usepackage[version=4]{mhchem} %化学反応式
\usepackage{expl3}
\usepackage{calc}
% \ce{6 CO2 + 12 H2O -> C6H12O6 + 6 O2 + 6 H2O}
%----------
% Mathematical Logic
\usepackage{turnstile}
% \renewcommand{\vdash}{\sststile{}{}}
% \renewcommand{\vDash}{\sdtstile{}{}}
% \renewcommand{\Vdash}{\dststile{}{}}
\usepackage{bussproofs}
\EnableBpAbbreviations
\renewcommand{\fCenter}{{}\Rightarrow{}}
\renewcommand{\RL}[1]{\RightLabel{{\scriptsize (#1)}}}
%%%%%%%%%% 自然演繹 
% \begin{prooftree}
% 0 \AXC { $ ... $ }  
% 1 \UIC { $ ... $ } 
% 2 \BIC { $ ... $ } 
% 3 \TIC { $ ... $ } 
% \end{prooftree}
%%%%%%%%%% シークエント計算
%\begin{prooftree}
% 0 \AX $ ...\fCenter... $
% 1 \UI $ ...\fCenter... $
% 2 \BI $ ...\fCenter... $
% 3 \TI $ ...\fCenter... $
%\end{prooftree}
%----------
\usepackage{qtree} %タブローパッケージ
%----------
\renewcommand{\labelitemi}{~$\bullet$~}
%\renewcommand{\labelitemii}{~\circ~}
\renewcommand{\labelitemii}{~$\triangleright$~}
%----------
\usepackage{emoji} %絵文字
% \setemojifont{EmojiOneMozilla}
\setemojifont{Noto Emoji Regular}
%----------
\newtheorem{definition}{定義}[section]
\newtheorem{proposition}[definition]{命題}
\newtheorem{theorem}[definition]{定理}
\newtheorem{lemma}[definition]{補題}
\newtheorem{corollary}[definition]{}
\newtheorem{example}[definition]{}
\newtheorem{practice}[definition]{演習問題}
% \newtheorem*{longproof}{証明}
\newtheorem*{answer}{解答}
\newtheorem*{supplement}{補足}
\newtheorem*{remark}{注意}
%----------
% 定理環境(tcolorbox)
\usepackage{tcolorbox} %箱
\tcbuselibrary{breakable,skins,theorems}
%----------
\tcolorboxenvironment{definition}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=3mm,bottom=3mm,
 before skip=15pt,after skip=15pt,
 borderline={0.5pt}{0pt}{black}
}
%----------
\tcolorboxenvironment{proposition}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=3mm,bottom=3mm,
 before skip=15pt,after skip=15pt,
 borderline={0.5pt}{0pt}{black}
}
%----------
\tcolorboxenvironment{theorem}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=3mm,bottom=3mm,
    sharp corners,boxrule=0.6pt,
 before skip=15pt,after skip=15pt,
 borderline={0.5pt}{0pt}{black},
    borderline={0.5pt}{1.5pt}{black}
}
%----------
\tcolorboxenvironment{lemma}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=3mm,bottom=3mm,
 before skip=15pt,after skip=15pt,
 borderline={0.5pt}{0pt}{black}
}
%----------
\tcolorboxenvironment{corollary}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=3mm,bottom=3mm,
 before skip=15pt,after skip=15pt,
 borderline={1.0pt}{0pt}{black,dotted}
}
%----------
\tcolorboxenvironment{example}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=3mm,bottom=3mm,
 before skip=15pt,after skip=15pt,
 borderline={0.5pt}{0pt}{black}
}
%----------
\tcolorboxenvironment{practice}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=3mm,bottom=3mm,
 before skip=15pt,after skip=15pt,
 borderline={0.5pt}{0pt}{black}
}
%----------
\tcolorboxenvironment{proof}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=1mm,bottom=1mm,
 before skip=15pt,after skip=20pt,
 % borderline west={1.5pt}{0pt}{black,dotted}
 borderline vertical={1pt}{0pt}{black,dotted}
 % borderline vertical={0.8pt}{0pt}{black,dotted,arrows={Square[scale=0.5]-Square[scale=0.5]}}
 }
%----------
\tcolorboxenvironment{supplement}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=1mm,bottom=1mm,
 before skip=15pt,after skip=20pt,
 % borderline west={1.5pt}{0pt}{black,dotted}
 % borderline vertical={0.5pt}{0pt}{black,arrows = {Circle[scale=0.7]-Circle[scale=0.7]}}
 borderline vertical={0.5pt}{0pt}{black}
 % borderline vertical={0.5pt}{0pt}{black},
 % borderline north={0.5pt}{0pt}{white,arrows={Circle[black,scale=0.7]-Circle[black,scale=0.7]}}
 }
%----------
\tcolorboxenvironment{remark}{
 blanker,breakable,
 left=3mm,right=3mm,
 top=1mm,bottom=1mm,
 before skip=15pt,after skip=20pt,
 % borderline west={1.5pt}{0pt}{black,dotted}
 % borderline vertical={0.5pt}{0pt}{black,arrows = {Circle[scale=0.7]-Circle[scale=0.7]}}
 borderline vertical={0.5pt}{0pt}{black}
 % borderline vertical={0.5pt}{0pt}{black},
 % borderline north={0.5pt}{0pt}{white,arrows={Circle[black,scale=0.7]-Circle[black,scale=0.7]}}
 }
%----------
% マークシート記号
\newcommand{\egg}[1]{\raisebox{-3pt}{
 \begin{tikzpicture}[x=1pt,y=1pt,line width=1pt]
 \draw (0,0) ellipse (4.5 and 6);
 \draw (0,0) node {
 \usefont{T1}{phv}{m}{n}
 \fontsize{9pt}{0}\selectfont #1 \/};
 \end{tikzpicture}}}
% マークシート記号
\newcommand{\eggg}[1]{\raisebox{-3pt}{
 \begin{tikzpicture}[x=1pt,y=1pt,line width=1pt]
 \draw[fill=black!30] (0,0) ellipse (4.5 and 6);
 \draw (0,0) node {
 \usefont{T1}{phv}{m}{n}
 \fontsize{9pt}{0}\selectfont #1 \/};
 \end{tikzpicture}}}
%-------------------- 
% UDカラー (アクセントカラー)
\definecolor{accentred}{rgb}{1.0, 0.3, 0.0}
\definecolor{accentyellow}{rgb}{1.0, 0.9, 0}
\definecolor{accentgreen}{rgb}{0.0, 0.7, 0.5}
\definecolor{accentblue}{rgb}{0.0, 0.35, 1.0}
\definecolor{accentsky}{rgb}{0.3, 0.76, 1.0}
\definecolor{accentpink}{rgb}{1.0, 0.5, 0.5}
\definecolor{accentorange}{rgb}{0.96, 0.67, 0.0}
\definecolor{accentpurple}{rgb}{0.6, 0.0, 0.6}
%--------------------
% UDカラー (ベースカラー)
\definecolor{basepink}{rgb}{1.0, 0.8, 0.75}
\definecolor{basecream}{rgb}{1, 1, 0.5}
\definecolor{baseyellowgreen}{rgb}{0.8, 0.94, 0.33}
\definecolor{basesky}{rgb}{0.75, 0.9, 1.0}
\definecolor{basebeige}{rgb}{1.0, 0.8, 0.5}
\definecolor{basegreen}{rgb}{0.47, 0.85, 0.65}
\definecolor{basepurple}{rgb}{0.8, 0.67, 0.9}
%--------------------
\definecolor{basegray}{rgb}{0.784,0.784,0.796}
%--------------------
% \pagestyle{empty}  %% ページ番号を消す
% \renewcommand{¥qedsymbol}{¥parallel}
%--------------------


プリアンブルだけでかなり長いので,
別ファイル (preamble.tex) に分けたうえで
同じフォルダ内に保存します。

これを main.tex 内で



\input preamble.tex


と書いて呼び出しています。

なお,ここに挙げたパッケージについては,
僕が日常的に使っているものを
使用頻度にかかわらず
すべて網羅してあります。
なぜなら,いちいち使うたびに
どのパッケージを呼び出すか考えて
取捨選択するのは面倒だからです。

それぞれのパッケージの使用方法は
公式ドキュメントを読んで確認してください。

蛇足ですが,
パッケージの仕様を知りたいときには,
なんだかんだ,地道に
公式ドキュメントを読むのが
近道です。
最近では,パッケージの使用方法を
手軽に紹介するブログ記事が
たくさんありますが,
そんな水で薄めたものを
読むくらいなら,
公式ドキュメントを
原液のまま飲んだほうがましです。

(3) 個々の分割ファイル
1_1_xxxxxx.tex
1_2_xxxxxx.tex 
2_1_xxxxxx.tex  など



%----------
\documentclass[
 book,
 head_space=20mm,
 foot_space=20mm,
 gutter=10mm,
 line_length=190mm
]{jlreq}
%----------
\input 0_preamble.tex
%----------
\begin{document}


\chapter{章のタイトル}


\section{節のタイトル}


あいうえお


\end{document}


このように,各章,各節ごとに
ファイルを分けて保存します。

そして main.tex 内で

%---------- 1章1節
\input 1_1_xxxxxxx.tex

%---------- 1章2節
\input 1_2_xxxxxxx.tex

---------- 2章1節
\input 2_1_xxxxxxx.tex


と書けば,ひとつの文書全体の中に
諸部分をまとめて表示できます。
main.tex をタイプセットすれば,
まとまった1つのPDFが得られます。

また,ファイル分割を効率よく実現するために,
main.tex には \usepackage{docmute}
を使用しています。
そのため,個々のファイルは,それぞれ単独でも
タイプセットすることが可能です。

つまり,章ごと節ごとのPDFも
手軽に出力できます。

使い分けとしては,
・編集中は,章ごと節ごとのPDFを出力する。
・閲覧用としては,まとまった1つのPDFにする。
とすればよいです。

このふたつを使い分ければ,
勉強用ノートの分量が増えて
100ページや200ページなどに
かさばった場合にも,
管理が楽になってかなり便利です。

以上です。

同一フォルダ内に

0_preamble.tex
1_1_xxxxxxx.tex
1_2_xxxxxxx.tex
……
2_1_xxxxxx.tex
……
main.tex

を置くだけで,すぐ利用可能です。

このように仕様を工夫すれば,
100ページを超える膨大な勉強メモも
効率よく管理することができます。



追記:
Mac での VSCode の settings.json の設定も,
一から調べて設定すると面倒なので,
以下に覚え書きとして載せておきます。
(LuaLaTeXユーザー必見)

{"latex-workshop.latex.recipes": [
  {
    "name": "lualatex",
    "tools": ["lualatex"]
  }
],
"latex-workshop.latex.tools": [
  {
    "name": "lualatex",
    "command": "lualatex",
    "args": [
      "--cmdx",
      "-file-line-error",
      "-synctex=1",
      "-interaction=nonstopmode",
      "-halt-on-error",
      "%DOC%"
    ],
    "env": {}
  }
],
"editor.wordWrap": "on",
"[latex]": {
  "editor.wordWrap": "on"
},
"window.zoomLevel": 1,
"editor.acceptSuggestionOnEnter": "off",
"json.schemas": []
}
copy

以上です。

大学生向け・有益なサイトURL(備忘録)

(このURL集は、自分用にまとめたものですが、みなさま存分にフル活用していただいて構いません。ここに載せてあるのは全て、私自身が日常的に使用していて良いと感じたものの厳選です。URLは随時増えていく予定。)

 

↓量が多いので、目次で飛んだほうがはやい。

1. 情報ツール編

チェック・情報収集

記録や保管のツール

ソーシャル系

その他の便利ツール

2. データベース・統計資料・アーカイブ資料など

 

3. 学習コンテンツ・学習ツール編

学び全般 (MOOCやOpenCourseWareなど)

数学

統計学機械学習

簿記会計

コンピュータ

理科系(というかほとんど物理)

語学

古典語(ラテン語ギリシャ語)

日本語くずし字の自動判読ツール

文学・短歌・俳句など

音楽・音楽理論

地形・地理・気候・災害・その他

 

4. 自主制作映画・映像

映画祭

役者募集・ロケーション・フィルムコミッション

3DCG(おもにBlender)

その他映像全般

 

5. デザイン

ガイドライン

配色

フォント

 

 

6. 高校までの学習内容の復習がしたいとき

社会科

数学

物理

 

7. 団体・活動・勉強会など

個人的に興味のありそうなもの

おもに中高生向け(おすすめ)の団体・活動・勉強会など(どちらかというと理系寄り)

8. 美術館・博物館・資料館・劇場・など

美術館

博物館

映画館

舞台演劇(オペラや歌舞伎など)

 

9. その他

映画映像 (映像制作/アニメーション/脚本/作品応募など)

文学賞(作品応募などの情報)

その他