> 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/xiang-xi-ji-shi/28-how-to-use-latexmkrc-with-overleaf.md).

# Overleafでlatexmkrcを使う方法

〜を聞いたことがあるなら手を挙げて `latexmkrc` ファイル？ それが何をするものか知っているなら、手を挙げたままでいてください。さらに、自分で書いたことがあるなら、手を挙げたままでいてください。まだ手を挙げている人は――この投稿の残りを読む必要はたぶんありません。

なぜ〜に興味があるのか `latexmkrc`？ 最近、Overleaf で特定のことをどうやって行うかについて問い合わせるユーザーが何人もいて、その答えとして私たちは「まず、カスタムの `latexmkrc` ファイルをプロジェクトに作成してください…」。これは LaTeX の中でもあまり直感的ではない部分であり、Web 上のドキュメント（特に例）はかなり少ないので、ここで少し詳しく見ていこうと思いました。

### latexmkrc ファイルとは何ですか？

もし見たことがないなら、 `latexmkrc` ファイルは、〜の設定／初期化（RC）ファイルです [`Latexmk` パッケージを](https://www.ctan.org/pkg/latexmk). `Latexmk` Overleaf がソースの LaTeX 文書を最終的な組版済み PDF ファイルにコンパイルする際の制御に使われます。というカスタム設定ファイルを使うことで *`Latexmk`* 既定のコンパイルコマンドを上書きして、Overleaf が文書を特別な方法でコンパイルできるようにします。

### なぜ latexmkrc ファイルを使いたいのでしょうか？

たとえば、Overleaf でコンパイルされた PDF 内のすべての日付と時刻が、デフォルトではサーバーの日時になっていることをご存じでしたか。代わりにローカルの日付／時刻を使いたい場合はどうでしょう？

お使いのタイムゾーンに合わせたローカルの日付／時刻を表示するには、 `TZ` カスタムの（タイムゾーン）環境変数を使用して `latexmkrc` ファイル:

1. プロジェクトのエディタ画面で、ファイルツリーの上部にある「Upload」アイコンをクリックします。
2. 「New file」を選択し、ファイルに名前を付けます `latexmkrc`.
3. 次の行をファイルに追加します `latexmkrc`:

   ```perl
   $ENV{'TZ'}='Canada/Central';
   ```

   あるいは、必要な任意のタイムゾーンです。以下は [参考用のサポート対象タイムゾーン一覧](http://php.net/manual/en/timezones.php).

日付と時刻（例： `\today` や `\currenttime` の `datetime` パッケージ）は、その後、指定したタイムゾーンのローカル値を表示するはずです。

1つの `latexmkrc` ファイルは、致命的なエラーのあるプロジェクトをデバッグするのに非常に役立ちます。詳細は次の [コンパイルタイムアウトのヘルプページ](/latex/ja/narejjibsu/038-fixing-and-preventing-compile-timeouts.md#fatal-compile-errors-blocking-the-compilation).

### latexmkrc コマンドの例はどこで見つけられますか？

まずは、ヘルプページの以下の例をご覧ください：

* [Overleaf はどのように私のプロジェクトをコンパイルするのですか？](/latex/ja/narejjibsu/064-how-does-overleaf-compile-my-project.md)
* [Overleaf で plain TeX を実行できますか？](/latex/ja/to-2/05-can-i-run-plain-tex-on-overleaf.md)
* [Overleaf は pTeX をサポートしていますか？](/latex/ja/to-2/09-does-overleaf-support-ptex.md)
* [コンパイルを妨げている致命的なコンパイルエラーを見つける](/latex/ja/narejjibsu/038-fixing-and-preventing-compile-timeouts.md#fatal-compile-errors-blocking-the-compilation)
* [たくさんの .cls、.sty、.bst ファイルがあり、プロジェクトをすっきりさせるためにフォルダにまとめたいのですが、プロジェクトがそれらを見つけられず、正しくコンパイルできません。](/latex/ja/to-2/59-i-have-a-lot-of-.cls-.sty-.bst-files-and-i-want-to-put-them-in-a-folder-to-keep-my-project-unclut.md)
* [Overleaf で xr パッケージを動作させるにはどうすればよいですか？](/latex/ja/narejjibsu/033-cross-referencing-with-the-xr-package-in-overleaf.md)
* [\today に自分のタイムゾーンに応じた日付を表示させるにはどうすればよいですか？](/latex/ja/to-2/32-how-do-i-make-today-display-the-date-according-to-my-time-zone.md) （その例は上で再利用されています）

それでも解決しない場合は、どうぞお気軽に [お問い合わせページ](https://www.overleaf.com/contact) または、人気の [TeX Stack Exchange](http://tex.stackexchange.com) や [LaTeX Community](http://latex-community.org/) フォーラムをご利用ください。


---

# 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/xiang-xi-ji-shi/28-how-to-use-latexmkrc-with-overleaf.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.
