> 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/commands/01-commands.md).

# 명령

## 소개

이 글은 다음에 대한 첫 소개를 제공합니다. *명령*이는 LaTeX의 조판 기능에서 핵심적인 구성 요소입니다. 대부분의 LaTeX 명령은 특수 문자, 보통 `\`인 백슬래시 문자로 앞에 붙는 단순한 단어입니다. 몇 가지 예를 살펴보겠습니다:

```latex
\documentclass{article}
\begin{document}
문서에는 서로 다른 유형의 \textbf{명령}이 있으며
이는 요소가 표시되는 방식을 정의합니다. 이
명령은 특별한 요소를 삽입할 수 있습니다: $\alpha \beta \Gamma$
\end{document}
```

[Overleaf에서 이 예제를 엽니다.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+commands+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0AIn+a+document+there+are+different+types+of+%5Ctextbf%7Bcommands%7D+%0Athat+define+the+way+the+elements+are+displayed.+This+%0Acommands+may+insert+special+elements%3A+%24%5Calpha+%5Cbeta+%5CGamma%24%0A%5Cend%7Bdocument%7D)

이 예제는 다음 출력을 생성합니다:

![LaTeX를 사용한 기본 텍스트 서식](/files/cf30a81144d7dfc5dcd0142886cf1fc437afda50)

앞의 예에는 여러 종류의 명령이 있습니다. 예를 들어, `\textbf` 는 명령에 매개변수로 전달된 텍스트를 굵게 표시합니다. 수학 모드에는 다음과 같은 특수 명령이 있습니다. `\alpha`, `\beta` 및 `\Gamma` 그리스 문자를 표시하기 위해 사용됩니다.

## 명령

다음은 글머리표 목록을 만들기 위한 명령이 포함된 LaTeX 코드의 예입니다:

```latex
\documentclass{article}
\begin{document}
목록 예시:
\begin{itemize}
  \item[\S] 첫 번째 항목
  \item 두 번째 항목
\end{itemize}
\end{document}
```

[Overleaf에서 이 예제를 엽니다.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+itemized+list+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0AA+list+example%3A%0A%5Cbegin%7Bitemize%7D%0A++%5Citem%5B%5CS%5D+First+item%0A++%5Citem+Second+item%0A%5Cend%7Bitemize%7D%0A%5Cend%7Bdocument%7D)

이 예제는 다음 출력을 생성합니다:

![LaTeX에서 조판한 기본 목록](/files/11618322727d509771357748616cbb1c960509db)

명령은 `\begin{itemize}` 을 시작합니다 `itemize` *환경은*—다음의 [환경에 관한 글](/latex/ko/commands/02-environments.md) 을 참고하세요. 더 자세한 내용은 환경 선언 아래에 명령 `\item` 가 있습니다. 이는 LaTeX에 새 목록 항목을 시작하라고 지시합니다. 서식을 지정하기 위해 특수한 표시(글머리표라고 하는 작은 검은 점)를 추가하고 항목을 들여씁니다.

일부 명령은 하나 이상의 *매개변수*; 예를 들어, `\textbf` 명령(위에서 사용됨)을 필요로 합니다. 이 명령은 단일 매개변수—굵은 글씨로 표시할 텍스트—를 받아들이며, 다음과 같이 중괄호 안에 작성합니다: `\textbf{이것을 굵게}`.

또한 *선택적* 명령에 전달하여 동작을 바꿀 수 있는 매개변수도 있습니다. 이러한 선택적 매개변수는 대괄호 안에 넣어야 합니다: `[...]`. 위의 예에서 명령 `\item[\S]` 는 다음과 동일하게 동작하지만 `\item`, 대괄호 안에 `\S`가 들어 있다는 점이 다르며, 이는 항목 텍스트 앞의 검은 점을 대체할 다른 문자를 대신합니다.

## 새 명령 정의하기

LaTeX에는 수많은 명령이 포함되어 있지만, 작업을 단순화하고 반복 작업을 줄이거나 일부 복잡한 서식을 수행하기 위해 자신만의 특수 명령을 정의해야 하는 경우가 종종 있습니다.

### 간단한 명령

새 명령은 다음과 같이 정의됩니다. `\newcommand`; 간단한 예를 보겠습니다:

```latex
\documentclass{article}
\usepackage{amssymb}
\begin{document}
\newcommand{\R}{\mathbb{R}}
실수 집합은 보통
검은판 굵은 대문자 R로 나타냅니다: \( \R \).
\end{document}
```

[Overleaf에서 이 예제를 엽니다.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Creating+a+simple+command\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamssymb%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewcommand%7B%5CR%7D%7B%5Cmathbb%7BR%7D%7D%0AThe+set+of+real+numbers+are+usually+represented+%0Aby+a+blackboard+bold+capital+R%3A+%5C%28+%5CR+%5C%29.%0A%5Cend%7Bdocument%7D)

이 예제는 다음 출력을 생성합니다:

![새 명령의 출력](/files/a3b803f69bf151148a8c1d72f2fc054d7bc0357c)

다음 문장은 `\newcommand{\R}{\mathbb{R}}` 새 명령을 정의하는 두 개의 매개변수를 가지며, 여기서:

* `\R`: 는 새 명령의 이름입니다.
* `\mathbb{R}`: 는 새 명령이 하는 일입니다. 이 경우 문자 R은 검은판 굵은 글꼴 스타일로 쓰입니다.  `\mathbb` 명령의 사용에는 `amssymb` 패키지가 필요하며, 이는 위의 예(서문)에 추가되었습니다.

명령이 정의되면 위에서 보여준 것처럼 본문에서 사용할 수 있습니다. 이 예에서는 새 명령이 사용되는 문단 바로 앞에 정의되어 있지만, 이런 정의를 문서 전체에 흩어 놓는 것은 좋은 관행으로 간주되지 않습니다. 일반적으로 새 명령의 정의는 문서 서문에 모아 두거나, 더 큰 모음의 경우 별도의 파일에 넣어 다음과 같이 [기본 문서로 불러올 수 있습니다](/latex/ko/document-structure/07-management-in-a-large-project.md#inputting-and-including-files).

### 매개변수가 있는 명령

일부 매개변수를 받는 새 명령을 만드는 것도 가능합니다. 예를 들어:

```latex
\documentclass{article}
\usepackage{amssymb}
\begin{document}
\newcommand{\bb}[1]{\mathbb{#1}}
다른 수 체계도 비슷한 표기를 사용합니다.
복소수 \( \bb{C} \), 유리
수 \( \bb{Q} \) 및 정수 \( \bb{Z} \).
\end{document}
```

[이 예제를 Overleaf에서 열기](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+command+with+1+parameter\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamssymb%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewcommand%7B%5Cbb%7D%5B1%5D%7B%5Cmathbb%7B%231%7D%7D%0AOther+numerical+systems+have+similar+notations.+%0AThe+complex+numbers+%5C%28+%5Cbb%7BC%7D+%5C%29%2C+the+rational+%0Anumbers+%5C%28+%5Cbb%7BQ%7D+%5C%29+and+the+integer+numbers+%5C%28+%5Cbb%7BZ%7D+%5C%29.%0A%5Cend%7Bdocument%7D)

이 예제는 다음 출력을 생성합니다:

![매개변수가 있는 LaTeX 명령의 출력](/files/11c221263ad374724eaeadf6135f610ac20fbce9)

다음 줄 `\newcommand{\bb}[1]{\mathbb{#1}}` 하나의 매개변수를 받는 새 명령을 정의하며, 여기서:

* `\bb` 는 새 명령의 이름입니다.
* `[1]` 는 새 명령이 받을 매개변수의 수입니다.
* `\mathbb{#1}` 는 명령이 실제로 수행하는 동작—즉, 그 정의입니다.

이 경우, `#1`로 참조되는 매개변수는 검은판 굵은 글자로 작성됩니다. 명령에 둘 이상의 매개변수가 필요하면 각 매개변수를 `#1`, `#2` 등을 사용하여 참조할 수 있습니다. 최대 9개의 매개변수를 지원합니다.

### 선택적 매개변수가 있는 명령

사용자 정의 명령은 지금까지의 예보다 더 유연하게 만들 수 있습니다: *선택적* 개의 매개변수를 받는 명령을 정의할 수 있습니다:

```latex
\documentclass{article}
\begin{document}

지수 표현이 많은 식을 작성할 때 적절한 명령을 정의하면 작업을 단순화하고 시간을 절약할 수 있습니다:

\newcommand{\plusbinomial}[3][2]{(#2 + #3)^#1}

다음과 같이 사용할 수 있습니다: \[ \plusbinomial{x}{y} \]

그리고 지수까지 바꿀 수 있습니다:

\[ \plusbinomial[4]{a}{b} \]
\end{document}
```

[Overleaf에서 이 예제를 엽니다.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+command+with+optional+parameters\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%0AWhen+writing+many+expressions+with+exponents+we+can+simplify+our+task%2C+and+save+time%2C+by+defining+a+suitable+command%3A%0A%0A%5Cnewcommand%7B%5Cplusbinomial%7D%5B3%5D%5B2%5D%7B%28%232+%2B+%233%29%5E%231%7D%0A%0AWe+can+use+it+like+this%3A+%5C%5B+%5Cplusbinomial%7Bx%7D%7By%7D+%5C%5D%0A%0AAnd+even+the+exponent+can+be+changed%3A%0A%0A%5C%5B+%5Cplusbinomial%5B4%5D%7Ba%7D%7Bb%7D+%5C%5D%0A%5Cend%7Bdocument%7D)

이 예제는 다음 출력을 생성합니다:

![선택적 매개변수가 있는 명령의 출력](/files/a2fd5f3dd5b12b6e149e9ead6d27e8e005cf1050)

다음 줄의 구문을 살펴봅시다 `\newcommand{\plusbinomial}[3][2]{(#2 + #3)^#1}`:

* `\plusbinomial` 는 새 명령의 이름입니다.
* `[3]` 는 명령이 받을 매개변수의 수를 나타내며, 이 경우 3입니다.
* `[2]` 는 첫 번째 매개변수의 기본값입니다. 이는 첫 번째 매개변수를 선택적으로 만드는 요소이며, 전달되지 않으면 이 기본값을 사용합니다.
* `(#2 + #3)^#1` 는 명령이 수행하는 동작입니다. 이 경우 두 번째와 세 번째 매개변수를 첫 번째 매개변수가 나타내는 거듭제곱의 "이항식 형식"으로 넣습니다.

## 기존 명령 덮어쓰기

새 명령을 정의하려고 할 때 그 이름이 *이미 존재하는* LaTeX 명령과 같다면 컴파일이 오류 메시지와 함께 실패합니다. 이는 다음 예에서 기존의 `\textbf` 명령:

```latex
\documentclass{article}
\newcommand{\textbf}[1]{#1}% 이것은 작동하지 않습니다
\begin{document}

\section{이것은 실패할 것입니다}
\end{document}
```

[이 (**오류를 생성하는**) 예제를 Overleaf에서 열어 보세요.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Duplicate+command+name\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cnewcommand%7B%5Ctextbf%7D%5B1%5D%7B%231%7D%25+This+will+not+work%0A%5Cbegin%7Bdocument%7D%0A%0A%5Csection%7BThis+will+fail%7D%0A%5Cend%7Bdocument%7D)

이 예제를 컴파일하면 다음과 같은 출력이 생성됩니다:

![중복된 LaTeX 명령 정의로 인해 생성된 오류](/files/3d10340557f06e40598af85cde799756904742b3)

화면 이미지에서 보듯이, `\textbf` 를 정의하려는 시도는 실패했습니다. LaTeX가 다음 오류 메시지를 생성했습니다. **LaTeX 오류: 명령 \textbf 가 이미 정의되어 있습니다**.

정말로 기존 명령을 덮어쓰고 싶다면 다음과 같이 할 수 있습니다. `\renewcommand`으로, 이는 다음과 같은 구문을 사용합니다. `\newcommand`:

```latex
\documentclass{article}
\usepackage{amssymb}
\begin{document}

\renewcommand{\S}{\mathbb{S}}

리만 구면(복소수에 $\infty$를 더한 것)은
때때로 \( \S \)로 나타냅니다.
\end{document}
```

[Overleaf에서 이 예제를 엽니다.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Redefine+existing+command\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamssymb%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5Crenewcommand%7B%5CS%7D%7B%5Cmathbb%7BS%7D%7D%0A%0AThe+Riemann+sphere+%28the+complex+numbers+plus+%24%5Cinfty%24%29+is+%0Asometimes+represented+by+%5C%28+%5CS+%5C%29.%0A%5Cend%7Bdocument%7D)

이 예제는 다음 출력을 생성합니다:

![재정의된 LaTeX 명령의 출력](/files/903ea71df7d1ef829bc2dc7c1ee4eada04b9e751)

이 예에서 명령 `\S` (위의 [명령](#commands) 섹션의 예를 보세요)는 검은판 굵은 S를 출력하도록 덮어써집니다.

## 추가 읽을거리

자세한 내용은 다음을 참조하세요:

* [환경](/latex/ko/commands/02-environments.md)
* [패키지와 클래스 파일 이해하기](/latex/ko/class-files/01-understanding-packages-and-class-files.md)
* [사용자 정의 패키지 작성하기](/latex/ko/class-files/03-writing-your-own-package.md)
* [자신만의 클래스 작성하기](/latex/ko/class-files/04-writing-your-own-class.md)
* [LaTeX의 길이](/latex/ko/formatting/01-lengths-in-latex.md)
* [LaTeX에서 색상 사용](/latex/ko/formatting/13-using-colors-in-latex.md)
* [페이지 크기 및 여백](/latex/ko/formatting/07-page-size-and-margins.md)
* [패키지와 클래스 파일 목록](/latex/ko/class-files/02-overleaf-and-tex-live.md)
* [LaTeX2ε에 대한 그다지 짧지 않은 소개](http://www.ctan.org/tex-archive/info/lshort/)
* [WikiBooks의 LaTeX/Creating\_Packages](http://en.wikibooks.org/wiki/LaTeX/Creating_Packages)


---

# 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/commands/01-commands.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.
