> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/ja/sononotopikku/26-how-to-write-a-latex-class-file-and-design-your-own-cv-part-2.md).

# LaTeXクラスファイルの書き方と自分だけの履歴書のデザイン（第2部）

[第1部](/latex/ja/sononotopikku/25-how-to-write-a-latex-class-file-and-design-your-own-cv-part-1.md) | パート2

**著者: Cody Herring（2013年6月）**

これは〜の続きです [LaTeXクラスファイルの書き方と、自分だけのCVをデザインする方法（パート1）](/latex/ja/sononotopikku/25-how-to-write-a-latex-class-file-and-design-your-own-cv-part-1.md)、CVを作成するためのより多くのオプションと、そのためにクラスファイルを使う方法を説明します。

前回の記事では、2つのファイルが作成されました: `cv.tex` や `my_cv.cls`。コンテンツファイル、 `cv.tex`、次の内容が含まれていました:

```latex
\documentclass{my_cv}
\begin{document}
\section{教育}
\datedsubsection{University of Nowhere}{2004-2008}
\section{職歴}
\datedsubsection{ABC Limited}{2008-Now}
\end{document}
```

`my_cv.cls` には、いくつかの書式設定のデフォルトと、使用するいくつかのコマンドが含まれていました:

```latex
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{my_cv}[6/6/2013 カスタムCVクラス]
\LoadClass{article}
\RequirePackage{titlesec}
\titleformat{\section}       % \section コマンドをカスタマイズ
{\Large\scshape\raggedright} % \section 見出しを大きく（\Large）、
                             % スモールキャピタル（\scshape）にして左揃え（\raggedright）にする
  {}{0em}            % すべてのセクションに 'Section ...' のような接頭辞を付けるために使えます
  {}                 % 見出しの前にコードを挿入するために使えます
  [\titlerule]       % 見出しの後に水平線を挿入
  \titleformat{\subsection}
  {\large\scshape\raggedright}
  {}{0em}
  {}
\newcommand{\datedsection}[2]{%
  \section[#1]{#1 \hfill #2}%
}
\newcommand{\datedsubsection}[2]{%
  \subsection[#1]{#1 \hfill #2}%
}
```

これにより、次の文書が生成されます:

![Figure 1.png](/files/78e0b2596155e0aba1d82a4ce98c3a31749da0aa)

この `#1` や `#2` コマンドに渡される最初と2番目の引数、またはパラメータを指します。ある `\newcommand`、括弧内のセクション、たとえば `[2]` は、関数に渡されるパラメータの数を指します。関数はその後、 `#1`, `#2`を使ってこれらのパラメータを呼び出せます。必要なパラメータ数に応じて、という具合です。より多くのパラメータを持つ関数については、記事の後半で示します。

名前と連絡先のセクションを追加しつつ、経験やその他のセクションも続けていきます。

### 名前と連絡先情報

CVでは、名前は通常最上部にあり、連絡先情報は求人応募用に記載します。これは、クラスファイルに新しい関数を追加することで実現します。名前は簡単な関数で追加できます:

```latex
\newcommand{\name}[1]{%
  \centerline{\Huge{#1}}
}
```

これにより、使用する場所に中央揃えの大きなフォントの名前が表示されます。呼び出し方は次のとおりです:

```latex
\name{John Smith}
```

では、連絡先情報です。クラスファイルに次を追加してください:

```latex
\newcommand\contact[5]{%
    \centerline{%
        \makebox[0pt][c]{%
            #1 {\large\textperiodcentered} #2 {\large\textperiodcentered} #3
            \ #4 \ \ #5%
        }%
    }%
}
```

次に、文書から関数を呼び出します:

```latex
\contact{123 Broadway}{London}{UK 12345}{john@smith.com}{(000)-111-1111}
```

これらすべてが見栄えよく表示され、名前と連絡先情報は次のようになります:

![Figure 2.png](/files/9ee8a3d84244b02e3340131ca9a527fc6b90cc6b)

これは、区切り記号の箇条点を挟んで連絡先情報をきれいに整形して表示します。必要に応じて、より長い住所用に第2の関数を追加して調整できます:

```latex
\newcommand{\longcontact}[5]{%
    \noindent
    #1\hfill {\large\textperiodcentered}\hfill #2\hfill
    {\large\textperiodcentered}\hfill #3\\
    #4\hfill #5%
}
```

![Screenshot3.png](/files/a29731acbd73aa0d9902c40f40faeba85e51feaf)

これは短い情報だと少し奇妙に見えますが、住所が特に長い場合には、より柔軟に使えます。この方法の最もよい点は、TeX文書側の変更が最小限で済むことです:

```latex
\longcontact{123 Broadway}{London}{UK 12345}{john@smith.com}{(000)-111-1111}
```

これがクラスファイルを使う主な理由です。文書内容への変更を最小限に抑えつつ、表示方法（内容の見せ方）を外部で制御できるようにすることです。

### 経験セクションの拡張

CVは、職歴の一覧だけでは不十分です。各項目の下に、その仕事で何をしたのかの説明も加えるべきです。仕事ごとに3つの箇条書きを入れるのは、詳細さと説明のバランスとして適切です。ノードを追加したり削除したりして簡単に調整できます。クラスファイルに次を追加してください:

```latex
\newcommand{\workitems}[3]{%
    \begin{itemize}
    \item #1
    \item #2
    \item #3
    \end{itemize}%
}
```

次を `.tex` ファイル：

```latex
\workitems
{新製品を開発}
{生産性を20\%向上}
{コストを1万ドル削減}
```

これで経験セクションが少し充実しました:

![Figure 4.png](/files/edaa020ca20bcce4cab81866b365d72c4763b0bb)

スキルセクションを追加すると、履歴書が一通り整います。LaTeXコードをあまり短くできなかったため、これはクラス関数なしで行いました:

```latex
\section{スキル}

\begin{tabular}{l l l l}
C\# & T-SQL & JavaScript & HTML \\
XML & JSON & SOAP & REST
\end{tabular}
```

その結果、次のようになります:

![Figure 5.png](/files/eed06a238d7d19675ee88fae90209c278a8c10c0)

### 結論

この2部構成の記事で、拡張して新しいセクションを追加できる、非常に基本的なCVテンプレートができたはずです。

クラスファイル全体は次のとおりです:

```latex
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{my_cv}[6/6/2013 カスタムCVクラス]
\LoadClass{article}
\RequirePackage{titlesec}

\titleformat{\section}
  {\Large\scshape\raggedright}
  {}{0em}
  {}
  [\titlerule]

  \titleformat{\subsection}
  {\large\scshape\raggedright}
  {}{0em}
  {}

\newcommand{\datedsection}[2]{%
  \section[#1]{#1 \hfill #2}%
}
\newcommand{\datedsubsection}[2]{%
  \subsection[#1]{#1 \hfill #2}%
}

\newcommand{\name}[1]{%
  \centerline{\Huge{#1}}%
}

\newcommand\contact[5]{%
    \centerline{%
        \makebox[0pt][c]{%
            #1 {\large\textperiodcentered} #2 {\large\textperiodcentered} #3
            \ #4 \ \ #5%
        }%
    }%
}

\newcommand{\longcontact}[5]{%
    \noindent
    #1\hfill {\large\textperiodcentered}\hfill #2\hfill
    {\large\textperiodcentered}\hfill #3\\
    #4\hfill #5%
}

\newcommand{\workitems}[3]{%
    \begin{itemize}
    \item #1
    \item #2
    \item #3
    \end{itemize}%
}
```

この `.tex` ファイルは次のとおりです:

```latex
\documentclass{my_cv}
\begin{document}
\name{John Smith}
\contact{123 Broadway}{London}{UK 12345}{john@smith.com}{(000)-111-1111}
\section{教育}
\datedsubsection{University of Nowhere}{2004-2008}
\section{職歴}
\datedsubsection{ABC Limited}{2008-Now}
\workitems
{新製品を開発}
{生産性を20\%向上}
{コストを1万ドル削減}

\section{スキル}
\begin{tabular}{l l l l}
C\# & T-SQL & JavaScript & HTML \\
XML & JSON & SOAP & REST
\end{tabular}

\end{document}
```

その結果、次の文書が生成されます:

![Figure 6.png](/files/ccf235425e3e631331f8ef075a49ecf64ef524bd)

このチュートリアルは、拡張の余地を残したCVの素晴らしい出発点になるはずです。

[第1部](/latex/ja/sononotopikku/25-how-to-write-a-latex-class-file-and-design-your-own-cv-part-1.md) | パート2


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/ja/sononotopikku/26-how-to-write-a-latex-class-file-and-design-your-own-cv-part-2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
