Skip to content

Instantly share code, notes, and snippets.

@ryo-ARAKI
Last active November 22, 2023 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryo-ARAKI/c4f55e2c4c57a5997700160cc6ea55df to your computer and use it in GitHub Desktop.
Save ryo-ARAKI/c4f55e2c4c57a5997700160cc6ea55df to your computer and use it in GitHub Desktop.
Unique commands and default setting for LaTeX
% 雑誌名の短縮形リスト
\DeclareSourcemap{%
\maps[datatype=bibtex,overwrite=true]{
\map{
\step[
fieldsource=journal,
match={Journal of Fluid Mechanics},
replace={J. Fluid Mech.}]%
\step[
fieldsource=journal,
match={Physical Review E},
replace={Phys. Rev. E}]%
\step[
fieldsource=journal,
match={Physical Review X},
replace={Phys. Rev. X}]%
\step[
fieldsource=journal,
match={Physical Review Letters},
replace={Phys. Rev. Lett.}]%
\step[
fieldsource=journal,
match={Physical Review Fluids},
replace={Phys. Rev. Fluids}]%
\step[
fieldsource=journal,
match={Physical Review Research},
replace={Phys. Rev. Res.}]%
\step[
fieldsource=journal,
match={Annual Review of Fluid Mechanics},
replace={Annu. Rev. Fluid Mech.}]%
\step[
fieldsource=journal,
match={Nature Communications},
replace={Nat. Comm.}]%
\step[
fieldsource=journal,
match={Fluid Dynamics Research},
replace={Fluid Dyn. Res.}]%
\step[
fieldsource=journal,
match={Journal of Computational Physics},
replace={J. Comput. Phys.}]%
\step[
fieldsource=journal,
match={Computer Physics Communications},
replace={Comput. Phys. Commun.}]%
\step[
fieldsource=journal,
match={Proceedings of the National Academy of Sciences},
replace={Proc. Natl. Acad. Sci. USA}]%
\step[
fieldsource=journal,
match={New Journal of Physics},
replace={New J. Phys.}]%
\step[
fieldsource=journal,
match={Theoretical and Applied Mechanics Letters},
replace={Theor. App. Mech. Lett.}]%
\step[
fieldsource=journal,
match={Physics of Fluids},
replace={Phys. Fluids}]%
\step[
fieldsource=journal,
match={Journal of Statistical Physics},
replace={J. Stat. Phys.}]%
\step[
fieldsource=journal,
match={Journal of Turbulence},
replace={J. Turbul.}]%
\step[
fieldsource=journal,
match={Physics Reports},
replace={Phys. Rep.}]%
\step[
fieldsource=journal,
match={European Physical Letters},
replace={EPL}]%
\step[
fieldsource=journal,
match={Journal of the Atmospheric Sciences},
replace={J. Atmos. Sci.}]%
\step[
fieldsource=journal,
match={Scientific Reports},
replace={Sci. Rep.}]%
\step[
fieldsource=journal,
match={Physica D: Nonlinear Phenomena},
replace={Physica D}]%
}
}
}
% +++++++++++++++++++++++++++++++++++++++++++
% 独自コマンドによるLaTeX設定の構築
% LaTeX,英語
% +++++++++++++++++++++++++++++++++++++++++++
%
% ===========================================
% フォント設定
% ===========================================
\usepackage{hyperref} % 図・表・参考文献へのリンク
\hypersetup{
colorlinks=true,
linkcolor=magenta,
citecolor=blue,
urlcolor=cyan
}
\usepackage[utf8]{inputenc} % utf-8を使うためのパッケージ
\usepackage{indentfirst}
\usepackage{times} % Use the times font
% \usepackage{palatino} % Uncomment to use the Palatino font
\usepackage{url}
%
% ===========================================
% 図・表関係
% ===========================================
\usepackage{here}
\usepackage{xcolor} % Specify colors by their 'svgnames', for a full list of all colors available see here: http://www.latextemplates.com/svgnames-colors
\usepackage{booktabs} % 表の横罫線
\usepackage{lscape} % 表などを90度回転させる
\usepackage{longtable} % ページをまたぐ表の作成
\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{~(\alph{subfigure})} % print like Fig.~1~(a)
\usepackage{tcolorbox} % 背景色ありの枠付きボックス
%
% ===========================================
% 数学記号
% ===========================================
\usepackage{bm, amsfonts, amsmath, amsthm, amssymb, ascmac} % mathabx
\usepackage{siunitx} %SI単位系を上手くやってくれる:\SI{数値}{単位},\si{単位}
\usepackage{mathtools}
\usepackage{physics}
\usepackage{empheq}
% https://tex.stackexchange.com/a/147461
\def\onedot{$\mathsurround0pt\ldotp$}
\def\cddot{% two dots stacked vertically
\mathbin{\vcenter{\baselineskip.67ex
\hbox{\onedot}\hbox{\onedot}}%
}}%
% mathematical environment
\usepackage{amsthm}
\theoremstyle{assumption}
\newtheorem*{assumption}{Assumption}
%
% ===========================================
% 参考文献のスタイルを独自定義
% ===========================================
\renewbibmacro{in:}{} % in: Some journal の "in:" を取る
\DeclareFieldFormat[article]{title}{#1} % 論文タイトルにダブルクォートをつけない
\DeclareSourcemap{%
\maps[datatype=bibtex,overwrite=true]{
% 雑誌名の短縮形.自分でリストを作る必要がある
\map{
\step[
fieldsource=journal,
match={Journal of Fluid Mechanics},
replace={J. Fluid Mech.}]%
\step[
fieldsource=journal,
match={Physical Review E},
replace={Phys. Rev. E}]%
\step[
fieldsource=journal,
match={Physical Review X},
replace={Phys. Rev. X}]%
\step[
fieldsource=journal,
match={Physical Review Letters},
replace={Phys. Rev. Lett.}]%
\step[
fieldsource=journal,
match={Physical Review Fluids},
replace={Phys. Rev. Fluids}]%
\step[
fieldsource=journal,
match={Physical Review Research},
replace={Phys. Rev. Res.}]%
\step[
fieldsource=journal,
match={Annual Review of Fluid Mechanics},
replace={Annu. Rev. Fluid Mech.}]%
\step[
fieldsource=journal,
match={Nature Communications},
replace={Nat. Comm.}]%
\step[
fieldsource=journal,
match={Fluid Dynamics Research},
replace={Fluid Dyn. Res.}]%
\step[
fieldsource=journal,
match={Journal of Computational Physics},
replace={J. Comput. Phys.}]%
\step[
fieldsource=journal,
match={Computer Physics Communications},
replace={Comput. Phys. Commun.}]%
\step[
fieldsource=journal,
match={Proceedings of the National Academy of Sciences},
replace={Proc. Natl. Acad. Sci. USA}]%
\step[
fieldsource=journal,
match={New Journal of Physics},
replace={New J. Phys.}]%
\step[
fieldsource=journal,
match={Theoretical and Applied Mechanics Letters},
replace={Theor. App. Mech. Lett.}]%
\step[
fieldsource=journal,
match={Physics of Fluids},
replace={Phys. Fluids}]%
\step[
fieldsource=journal,
match={Journal of Statistical Physics},
replace={J. Stat. Phys.}]%
\step[
fieldsource=journal,
match={Journal of Turbulence},
replace={J. Turbul.}]%
\step[
fieldsource=journal,
match={Physics Reports},
replace={Phys. Rep.}]%
\step[
fieldsource=journal,
match={European Physical Letters},
replace={EPL}]%
\step[
fieldsource=journal,
match={Journal of the Atmospheric Sciences},
replace={J. Atmos. Sci.}]%
\step[
fieldsource=journal,
match={Scientific Reports},
replace={Sci. Rep.}]%
\step[
fieldsource=journal,
match={Physica D: Nonlinear Phenomena},
replace={Physica D}]%
}
}
}
%
% ===========================================
% itemize/enumerateの行間調整
% ===========================================
%
\let\oldenumerate\enumerate
\let\olditemize\itemize
\renewcommand{\itemize}{
\olditemize
\setlength{\itemsep}{2pt} % 項目間
\setlength{\parskip}{2pt} % 段落間
\setlength{\parsep}{0pt}
}
\renewcommand{\enumerate}{
\oldenumerate
\setlength{\itemsep}{2pt} % 項目間
\setlength{\parskip}{2pt} % 段落間
\setlength{\parsep}{0pt}
}
% +++++++++++++++++++++++++++++++++++++++++++
% 独自コマンドによるLaTeX設定の構築
% Beamer,英語
% +++++++++++++++++++++++++++++++++++++++++++
%
\usepackage{/home/raraki/.config/LaTeX/mystyle}
\usepackage{tikz}
\usetikzlibrary{positioning}
%
% ===========================================
% Beamerテーマの設定
% ===========================================
\usetheme{boxes}
\usecolortheme{whale}
\usefonttheme{professionalfonts}
\usefonttheme[onlymath]{serif}
\setbeamertemplate{footline}[frame number]
\setbeamerfont{page number in head/foot}{family=\ttfamily,size=\large}
\setbeamertemplate{navigation symbols}{}
\usepackage{multicol}
\setlength{\columnsep}{3zh}
\setbeamercovered{transparent} % \pause や \onslide 環境など表示されるタイミング以外でも薄く表示する
%
% ===========================================
% itemize環境中で数式を使う際のスペーシングを修正
% cf. https://tex.stackexchange.com/questions/439869/problems-with-spacing-beamer-itemize-and-equation
% ===========================================
\g@addto@macro\normalsize{
\setlength\abovedisplayskip{5pt}
\setlength\belowdisplayskip{5pt}
\setlength\abovedisplayshortskip{5pt}
\setlength\belowdisplayshortskip{5pt}
}
%
% ===========================================
% フォント設定
% ===========================================
\usepackage{textgreek}
% ソースコードの表示:\begin{frame}[fragile]オプションが必要
\usepackage{listings}
\lstset{
language={Fortran},
basicstyle={\ttfamily},
keywordstyle={\color{blue}},
commentstyle={\color{green}},
stringstyle=\color{red},
tabsize=2,
breaklines=true,
}
% Re-define \emph by bold & italic
% https://tex.stackexchange.com/a/227644
\let\emph\relax
\DeclareTextFontCommand{\emph}{\bfseries\em}
%
% ===========================================
% 強調構文などの設定
% ===========================================
\newcommand{\stress}[1]{{\colorbox{Pink}{#1}}} % 強調箇所
\setbeamercolor{advanced}{fg=black,bg=Wheat} % 発展した情報を扱うための薄ピンク背景,黒文字の色付きbox
\setbeamercolor{stress}{fg=black,bg=Pink} % 強調を表すためのピンク背景・黒文字の色付きbox
\setbeamercolor{stress2}{fg=black,bg=Gold} % 強調を表すための黄色背景・黒文字の色付きbox
% tikzを使った強調構文
\newcommand{\highlight}[2][yellow]{\tikz[baseline=(x.base)]{\node[rectangle,rounded corners,fill=#1!30](x){#2};}}
\newcommand{\highlightcap}[3][yellow]{\tikz[baseline=(x.base)]{\node[rectangle,rounded corners,fill=#1!30](x){#2} node[below of=x, color=#1]{#3};}}
% itemize環境で赤いbulletを使う
\newenvironment{redenv}{\only{\setbeamercolor{local structure}{fg=red}}}{}
% hyperlinkに色をつけない
\hypersetup{colorlinks=false}
%
% ===========================================
% 補足ページに関する設定
% ===========================================
\usepackage{cancel}
\newcommand{\backupbegin}{
\newcounter{framenumberappendix}
\setcounter{framenumberappendix}{\value{framenumber}}
}
\newcommand{\backupend}{
\addtocounter{framenumberappendix}{-\value{framenumber}}
\addtocounter{framenumber}{\value{framenumberappendix}}
}
%
% ===========================================
% 参考文献の書式設定
% https://tex.stackexchange.com/questions/291296/biblatex-beamer-missing-citation-abbreviation-in-the-bibliography
% ===========================================
\renewcommand*{\labelalphaothers}{}
\DeclareLabelalphaTemplate{
\labelelement{
\field[final]{shorthand}
\field{labelname}
\field{label}
}
\labelelement{
\literal{\addhighpenspace}
}
\labelelement{
\field{year}
}
}
% +++++++++++++++++++++++++++++++++++++++++++
% 独自コマンドによるLaTeX設定の構築
% Beamer,日本語
% +++++++++++++++++++++++++++++++++++++++++++
%
\usepackage{/home/ryo/.config/LaTeX/mystyle_beamer}
\usepackage{/home/ryo/.config/LaTeX/mystyle_jpn}
\renewcommand{\kanjifamilydefault}{\gtdefault}% 和文をゴシックに
% +++++++++++++++++++++++++++++++++++++++++++
% Bibliography setting equivalent to my PhD thesis
% +++++++++++++++++++++++++++++++++++++++++++
% ===========================================
% Bibliography
% ===========================================
% Print 'number' field, not 'issue'
\renewbibmacro*{volume+number+eid}{%
\printfield{volume}%
\setunit*{\addnbspace}%
\printfield{number}%
\setunit{\addcomma\space}%
\printfield{eid}}
%
\DeclareFieldFormat[article]{volume}{\mkbibbold{#1}} % volume in bold font
\DeclareFieldFormat{note}{(#1)} % Add parentheses to note
%
% Drop quotation mark from title
% cf. https://tex.stackexchange.com/a/462137
\DeclareFieldFormat[article,inbook,incollection,inproceedings,patent,thesis,unpublished]{title}{#1\isdot}
%
% Put parentheses around volume number of journal
% cf. https://tex.stackexchange.com/a/81573
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}} % parentheses around number
%
% Update backref style
% cf. https://tex.stackexchange.com/a/36308
\DefineBibliographyStrings{english}{
backrefpage = {\lowercase{c}ited on page},
backrefpages = {\lowercase{c}ited on pages},
}
%
% Longer line for \bibnamedash
% cf. https://tex.stackexchange.com/a/239373
\setlength\bibhang{2.4em}%% two dashes and space
\renewcommand*\bibnamedash{\textemdash\textemdash\space}
%
% List of uncited reference
% cf. https://tex.stackexchange.com/a/6977
\DeclareBibliographyCategory{cited}
\AtEveryCitekey{\addtocategory{cited}{\thefield{entrykey}}}
% +++++++++++++++++++++++++++++++++++++++++++
% 独自コマンドによるLaTeX設定の構築
% LaTeX,日本語
% +++++++++++++++++++++++++++++++++++++++++++
%
\usepackage{/home/ryo/.config/LaTeX/mystyle}
\usepackage{otf} % otfフォント
\usepackage{pxjahyper} % しおりの文字化けを防止
%
% ===========================================
% 図,表,目次の設定
% ===========================================
\renewcommand{\figurename}{図}
\renewcommand{\tablename}{表}
\renewcommand{\contentsname}{目次}
%
% ===========================================
% biblatexのlangidによる日本語文献の識別子を定義
% cf. biblatex で日本語文献をサポート https://gist.github.com/idiotWu/4879a88a3e34618cc8215a43ba2e9fbd
% ===========================================
\AtEveryBibitem{
% langid={Japanese} で識別
\iffieldequalstr{langid}{Japanese} {
% コンマで区切り
\DeclareDelimFormat{finalnamedelim}{%
\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
\addspace\multinamedelim
}
% 名前を「姓 名」の順に
\DeclareNameFormat{default}{%
\usebibmacro{name:delim}{\namepartfamily\namepartgiven}%
\usebibmacro{name:hook}{\namepartfamily\namepartgiven}%
\namepartfamily\bibnamedelimc\namepartgiven%
\usebibmacro{name:andothers}
}
% URLの参照日付を年/月/日で表示
\DeclareFieldFormat{urldate}{%
(\thefield{urlyear}/\thefield{urlmonth}/\thefield{urlday}~に参照\isdot)
}
}{}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment