【Beamer】LaTeXでのスライド作成の方法
投稿日: 更新日:
環境💻
OS: Ubuntu 22.04.2 LTS (WSL2)
texエンジン: lualatex(1.17.0)
環境構築はこちら↓
Linux: https://www.ochappa.net/posts/latex-linux-setup
Windows: https://www.ochappa.net/posts/latex-win-setup
タイトルページを作成する
まずは以下のように入力してみてください。
\documentclass{beamer}
% テーマを選択
\usetheme{Copenhagen}
% 日本語対応
\usepackage[ipaex]{luatexja-preset}
\renewcommand{\kanjifamilydefault}{\gtdefault}%ゴシック体に設定
% 数式のフォント設定
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}
\usefonttheme{professionalfonts}%Beamerによる数式フォントの置き換えを阻止
% タイトル、日付など
\title{サンプルプレゼンテーション}
\subtitle{Beamerで作成}
\author{お茶の葉}
\institute{工学部}
\date{2023年01月01日}
\begin{document}
% タイトルフレームを作成
\frame{\maketitle}
\end{document}
すると、以下のようなページが作成されると思います。
また、コードの中に% テーマを選択
とあるようにテーマを選択することが出来ます。テーマは https://www.y-misc.org/tex/command/beamer-theme.html などにまとまっています。気に入ったテーマを選択してください。
フレームを追加してみる
「フレーム」とはスライド1ページの事です。以下のように\begin{frame}
と\end{frame}
で囲った部分が1つのフレームとなります。
\frametitle
でフレームのタイトルを、\framesubtitle
でサブタイトルを設定出来ます。
\begin{frame}
\frametitle{オイラーの公式}
\framesubtitle{複素平面と指数関数の関係}
オイラーの公式は以下の通りです:
\begin{equation}
e^{ix} = \cos{x} + i\sin{x}
\end{equation}
ここで、
\begin{itemize}
\item $e$ は自然対数の底(約2.71828)
\item $i$ は虚数単位($i^2 = -1$)
\item $x$ は実数
\end{itemize}
$x$の値に応じて、$e^{ix}$が複素平面上の単位円を描くことを示しています。
\end{frame}
以下のようなスライドが出来ます。
コード全体
コード全体
\documentclass{beamer}
% テーマを選択
\usetheme{Copenhagen}
% 日本語対応
\usepackage[ipaex]{luatexja-preset}
\renewcommand{\kanjifamilydefault}{\gtdefault}%ゴシック体に設定
% 数式のフォント設定
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}
\usefonttheme{professionalfonts}%Beamerによる数式フォントの置き換えを阻止
% タイトル、日付など
\title{サンプルプレゼンテーション}
\subtitle{Beamerで作成}
\author{お茶の葉}
\institute{工学部}
\date{2023年01月01日}
\begin{document}
% タイトルフレームを作成
\frame{\maketitle}
\begin{frame}
\frametitle{オイラーの公式}
\framesubtitle{複素平面と指数関数の関係}
オイラーの公式は以下の通りです:
\begin{equation}
e^{ix} = \cos{x} + i\sin{x}
\end{equation}
ここで、
\begin{itemize}
\item $e$ は自然対数の底(約2.71828)
\item $i$ は虚数単位($i^2 = -1$)
\item $x$ は実数
\end{itemize}
$x$の値に応じて、$e^{ix}$が複素平面上の単位円を描くことを示しています。
\end{frame}
\end{document}
16:9にする
コード冒頭の\documentclass{beamer}
を\documentclass[aspectratio=169]{beamer}
と変更すると変わります。
sectionとsubsection
セクションを作成出来ます。\begin{frame}
の上にセクション名を書きます。
\section{section1}
\subsection{subsecton1}
\begin{frame}
frame1
\end{frame}
目次を作る
目次のフレームは\frame{\tableofcontents}
で作成できます。
例えば以下のようなコードの場合
クリックして開く
\documentclass[aspectratio=169]{beamer}
% テーマを選択
\usetheme{Copenhagen}
% 日本語対応
\usepackage[ipaex]{luatexja-preset}
\renewcommand{\kanjifamilydefault}{\gtdefault}%ゴシック体に設定
% 数式のフォント設定
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}
\usefonttheme{professionalfonts}%Beamerによる数式フォントの置き換えを阻止
% タイトル、日付など
\title{サンプルプレゼンテーション}
\subtitle{Beamerで作成}
\author{お茶の葉}
\institute{工学部}
\date{2023年01月01日}
\begin{document}
% タイトルフレームを作成
\frame{\maketitle}
% 目次を生成
\frame{\tableofcontents}
\section{section1}
\subsection{subsecton1}
\begin{frame}
frame1
\end{frame}
\subsection{subsecton2}
\begin{frame}
frame2
\end{frame}
\subsection{subsecton3}
\begin{frame}
frame3
\end{frame}
\section{section2}
\begin{frame}
frame4
\end{frame}
\section*{section3}
\begin{frame}
frame5
\end{frame}
\end{document}
このような目次が生成されます。\section*{section3}
のようにアスタリスクをつけると目次に表示されません。