> 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/ko/knowledge-base/127-set-main-document.md).

# 메인 문서 설정

Overleaf의 메인 문서는 LaTeX가 가장 먼저 컴파일하도록 지정되는 파일입니다. 이는 프로젝트의 मुख्य 파일로, 다른 모든 부분(클래스, 패키지, 장 등)이 입력되는 곳입니다. 이것이 수동으로 설정되지 않으면 Overleaf는 프로젝트에서 다음을 포함하는 문서를 선택합니다. **`\documentclass[...]{...}`** 명령입니다. 이런 이유로 서문용 별도 파일이 있다면, 그 **`\documentclass[...]{...}`** 명령을 서문 파일에 넣기보다는 메인 문서의 시작 부분에 두는 것이 좋습니다. 이렇게 하지 않으면 서문만 컴파일됩니다. 프로젝트에서 메인 문서를 설정하려면, 왼쪽 상단 모서리의 메뉴를 클릭하기만 하면 됩니다:

![Lefthandmenu.PNG](/files/2e296e1bc26429e2467ac0c79a17615e7325ff2b)

그리고 다음으로 이동하여 **메인 문서**:

![Maindocument.PNG](/files/feac136c9eff18f8527f2362a79a86c879bd7408)

다음을 참조하세요 [여기](/latex/ko/document-structure/07-management-in-a-large-project.md) LaTeX에서 대규모 프로젝트를 관리하는 방법에 대해 더 알아보세요.

## 같은 프로젝트에서 여러 문서 컴파일하기

같은 프로젝트에서 서로 다른 문서를 빠르게 컴파일할 수 있도록, Overleaf는 편집기에서 열려 있는 파일이 다음을 포함하고 있으면 그 파일을 메인 문서로 컴파일합니다. **`\documentclass[...]{...}`** 명령입니다. 이는 다음을 사용해 편집할 때 특히 편리합니다. [**`subfiles`** 패키지](/latex/ko/document-structure/08-multi-file-latex-projects.md#the-subfiles-package).

## 메인 파일 선택과 관련된 문제

메인 파일은 항상 루트 디렉터리(어떤 폴더 안에도 있지 않은 위치)에 있어야 합니다. 그래야 모든 컴파일 단계가 올바른 디렉터리에서 실행되고, 필요한 보조 파일을 사용할 수 있습니다. 예를 들어 [색인을 추가할 때](/latex/ko/document-structure/04-indices.md). Overleaf에서 컴파일할 수 있도록 프로젝트를 재구성하는 몇 가지 팁을 확인해 보세요 [여기](/latex/ko/questions-and-answers/77-my-main-file-is-in-a-subfolder-but-this-is-not-allowed-on-overleaf.-but-i-don-t-want-to-change-my.md).

선택한 메인 파일이 폴더 안에 있고 루트 디렉터리에 같은 이름의 파일이 있다면, 선택한 파일 대신 루트 디렉터리에 있는 해당 이름의 파일이 컴파일됩니다. 예를 들어, `version1/main.tex` 가 메인 파일로 설정되어 있지만 `main.tex` 도 프로젝트에 있다면, `main.tex` 컴파일됩니다. 이 문제는 Overleaf에서 Latexmk가 실행되는 방식 때문에 발생합니다. 이로 인한 문제를 피하려면, Overleaf에서 컴파일하려는 파일마다 고유한 이름을 지정하세요.


---

# 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/ko/knowledge-base/127-set-main-document.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.
