> 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/figures-and-tables/05-tikz-package.md).

# TikZ 패키지

## 소개

[Ti*k*Z](https://en.wikipedia.org/wiki/PGF/TikZ) 는 아마도 LaTeX에서 그래픽 요소를 만들기 위한 가장 복잡하고 강력한 도구입니다. 간단한 예제를 시작으로, 이 글에서는 선, 점, 곡선, 원, 사각형 등을 그리는 몇 가지 기본 개념을 소개합니다.

먼저 다음 줄을 포함하여 `tikz` 패키지를 로드합니다 `\usepackage{tikz}` 문서의 서문에 추가한 다음, 다음을 사용하여 그래픽을 그립니다 `tikzpicture` 환경을 사용한다는 점뿐입니다.

```latex
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[gray, thick] (-1,2) -- (2,-4);
\draw[gray, thick] (-1,-1) -- (2,2);
\filldraw[black] (0,0) circle (2pt) node[anchor=west]{교차점};
\end{tikzpicture}
\end{document}
```

[이 예제를 Overleaf에서 열기](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=First+TikZ+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Btikz%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%5Bgray%2C+thick%5D+%28-1%2C2%29+--+%282%2C-4%29%3B%0A%5Cdraw%5Bgray%2C+thick%5D+%28-1%2C-1%29+--+%282%2C2%29%3B%0A%5Cfilldraw%5Bblack%5D+%280%2C0%29+circle+%282pt%29+node%5Banchor%3Dwest%5D%7BIntersection+point%7D%3B%0A%5Cend%7Btikzpicture%7D%0A%5Cend%7Bdocument%7D)

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

![OLV2tikz1.png](/files/f9abfa6dd9a3c1b067a1c833f8b244c9734cad0f)

이 예제에서는 두 개의 선과 한 개의 점이 그려집니다. 선을 추가하려면 명령 `\draw[gray, thick]` 는 다음을 가진 그래픽 요소를 정의합니다 *색상* 는 `회색` 그리고 `굵은` 선으로 그려집니다. 이 선은 실제로 두 끝점으로 정의되며, `(-1,2)` 및 `(2,-4)`, 다음으로 연결됩니다 `--`.

다음 *점은 실제로* 입니다 `원` 그려지는 `\filldraw[black]`, 이 명령은 원을 그릴 뿐만 아니라 검은색으로 채웁니다. 이 명령에서는 중심점 `(0,0)` 과 반지름 `(2pt)` 이 선언됩니다. 점 옆에는 `노드`가 있는데, 이는 실제로 텍스트 `교차점`을 포함하는 상자이며, 점의 `서쪽` 에 고정됩니다.

각 `;` 의 끝에 사용되는 세미콜론 `draw` 명령을 사용해.

참고: `tikzfigure` 환경은 figure 또는 이와 유사한 환경 안에 포함될 수 있습니다. 이 주제에 대한 자세한 내용은 [이미지 삽입](/latex/ko/more-topics/27-inserting-images.md) 글을 참조하세요.

## 기본 요소: 점, 선 및 경로

이 섹션에서는 더 정교한 그림을 만들기 위해 결합할 수 있는 몇 가지 기본 그래픽 요소를 만드는 방법을 보여주는 예제를 제공합니다.

```latex
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\draw (-2,0) -- (2,0);
\filldraw [gray] (0,0) circle (2pt);
\draw (-2,-2) .. controls (0,0) .. (2,-2);
\draw (-2,2) .. controls (-1,0) and (1,0) .. (2,2);

\end{tikzpicture}
\end{document}
```

[이 예제를 Overleaf에서 열기](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Second+TikZ+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Btikz%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Btikzpicture%7D%0A%0A%5Cdraw+%28-2%2C0%29+--+%282%2C0%29%3B%0A%5Cfilldraw+%5Bgray%5D+%280%2C0%29+circle+%282pt%29%3B%0A%5Cdraw+%28-2%2C-2%29+..+controls+%280%2C0%29+..+%282%2C-2%29%3B%0A%5Cdraw+%28-2%2C2%29+..+controls+%28-1%2C0%29+and+%281%2C0%29+..+%282%2C2%29%3B%0A%0A%5Cend%7Btikzpicture%7D%0A%5Cend%7Bdocument%7D)

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

![OLV2tikz2.png](/files/38cfb53d9e46725115dc2f2f961086b409a7b1d7)

이 예제에는 세 가지 기본 명령이 있습니다:

* **`\draw (-2,0) -- (2,0);`**: 이는 끝점이 `(-2,0)` 및 `(2,0)`.
* **`\filldraw [gray] (0,0) circle (2pt);`**: 점은 매우 작은 `회색` `원` 를 중심으로 생성되며 `(0,0)` 과 반지름은 `(2pt)`. 다음 `\filldraw` 명령은 요소를 그리고 특정 색상으로 채우는 데 사용됩니다. 더 많은 예제는 다음 섹션을 참조하세요.
* **`\draw (-2,2) .. controls (-1,0) and (1,0) .. (2,2);`**: 다음을 그립니다 [베지어 곡선](https://en.wikipedia.org/wiki/B%C3%A9zier_curve). 이를 정의하는 데 4개의 점이 있습니다: `(-2,2)` 및 `(2,2)` 는 그 끝점이며, `(-1,0)` 및 `(1,0)` 는 [*제어점*](https://en.wikipedia.org/wiki/Control_point_\(mathematics\)) 은 그것이 얼마나 "굽어 있는지"를 결정합니다. 이 두 점을 "인력점"으로 생각할 수 있습니다.

## 기본 기하 도형: 원, 타원 및 다각형

기하 도형은 더 단순한 요소로 구성할 수 있으므로, 원, 타원 및 호부터 시작해 봅시다.

```latex
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\filldraw[color=red!60, fill=red!5, very thick](-1,0) circle (1.5);
\fill[blue!50] (2.5,0) ellipse (1.5 and 0.5);
\draw[ultra thick, ->] (6.5,0) arc (0:220:1);
\end{tikzpicture}
\end{document}
```

[이 예제를 Overleaf에서 열기](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Third+TikZ+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Btikz%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cfilldraw%5Bcolor%3Dred%2160%2C+fill%3Dred%215%2C+very+thick%5D%28-1%2C0%29+circle+%281.5%29%3B%0A%5Cfill%5Bblue%2150%5D+%282.5%2C0%29+ellipse+%281.5+and+0.5%29%3B%0A%5Cdraw%5Bultra+thick%2C+-%3E%5D+%286.5%2C0%29+arc+%280%3A220%3A1%29%3B%0A%5Cend%7Btikzpicture%7D%0A%5Cend%7Bdocument%7D)

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

![TikzEx3.png](/files/db0548209986df1589280b0fec423356606336f5)

* **`\filldraw[color=red!60, fill=red!5, very thick](-1,0) circle (1.5);`**: 이 명령은 이전 섹션에서 다음을 그리는 데 사용되었습니다 *점은 실제로*, 하지만 이 경우 대괄호 안에 몇 가지 추가 매개변수가 있습니다. 아래에서 설명합니다:
  * **`color=red!60`**: 원 둘레의 색상은 60% 빨강("순수한" 빨강보다 더 옅음)으로 설정됩니다. LaTeX에서 사용할 수 있는 기본 색상 목록은 [참조 안내서](#reference-guide) 을 참조하고, [LaTeX에서 색상 사용](/latex/ko/formatting/13-using-colors-in-latex.md) 를 참조하여 자신만의 색상을 만드는 방법을 알아보세요.
  * **`fill=red!5`**: 원은 훨씬 더 옅은 붉은색으로 채워집니다.
  * **`very thick`**: 이 매개변수는 선의 두께를 정의합니다. 값의 전체 목록은 [참조 안내서](#reference-guide) 를 참조하세요.
* **`\fill[blue!50] (2.5,0) ellipse (1.5 and 0.5);`**: 타원을 만들려면 중심점 `(2.5,0)`와 두 개의 반지름, 즉 가로와 세로(`1.5` 및 `0.5` 을 각각 제공합니다. 또한 명령 `fill` 대신 `draw` 또는 filldraw를 사용하지 않는다는 점에 주의하세요. 이는 이 경우 외부 색상과 내부 색상을 구분할 필요가 없기 때문입니다.
* **`\draw[ultra thick, ->] (6.5,0) arc (0:220:1);`**: 이 명령은 `(6.5,0)`에서 시작하는 호를 그립니다. 추가 매개변수 `->` 는 호의 끝에 화살표가 있음을 나타냅니다. 시작점 외에도 시작 각도, 끝 각도, 반지름의 세 가지 값을 추가로 제공해야 하며, 여기서는 이 세 매개변수 값이 다음 형식으로 제공됩니다 `(0:220:1)`.

곡선 기하 도형 외에도 유사한 구문을 사용하여 직선으로 이루어진 요소를 만들 수 있습니다:

```latex
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[blue, very thick] (0,0) rectangle (3,2);
\draw[orange, ultra thick] (4,0) -- (6,0) -- (5.7,2) -- cycle;
\end{tikzpicture}
\end{document}
```

[이 예제를 Overleaf에서 열기](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Fourth+TikZ+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Btikz%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%5Bblue%2C+very+thick%5D+%280%2C0%29+rectangle+%283%2C2%29%3B%0A%5Cdraw%5Borange%2C+ultra+thick%5D+%284%2C0%29+--+%286%2C0%29+--+%285.7%2C2%29+--+cycle%3B%0A%5Cend%7Btikzpicture%7D%0A%5Cend%7Bdocument%7D)

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

![OLV2tikz4.png](/files/72c92a95c4b37d64355eb9d6ffc14104f0f6aaa4)

* **`\draw[blue, very thick] (0,0) rectangle (3,2);`**: 사각형은 특수 명령 `rectangle`으로 만들어집니다. 두 점을 제공해야 하며, 첫 번째 점은 "연필"이 사각형을 그리기 시작하는 위치이고 두 번째 점은 대각선 반대편 꼭짓점입니다.
* **`\draw[orange, ultra thick] (4,0) -- (6,0) -- (5.7,2) -- cycle;`**: 다각형을 그리려면 *닫힌* 직선 경로를 그립니다: 다음에서의 선 `(4,0)` 을 `(6,0)` 그리고 다음으로의 선 `(6,0)` 을 `(5.7,2)`. 다음 `cycle` 명령은 시작점과 끝점이 일치하여 "닫힌" 경로(도형)를 만들도록 한다는 의미이며, 그 결과 마지막 선분이 생성됩니다.

## 다이어그램

노드는 아마도 TikZ에서 가장 다재다능한 요소일 것입니다. 우리는 이미 도입부에서 한 개의 노드를 사용하여 그림에 텍스트를 추가했습니다. 다음 예제는 노드를 사용하여 다이어그램을 만듭니다.

```latex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
roundnode/.style={circle, draw=green!60, fill=green!5, very thick, minimum size=7mm},
squarednode/.style={rectangle, draw=red!60, fill=red!5, very thick, minimum size=5mm},
]
%Nodes
\node[squarednode]      (maintopic)                              {2};
\node[roundnode]        (uppercircle)       [above=of maintopic] {1};
\node[squarednode]      (rightsquare)       [right=of maintopic] {3};
\node[roundnode]        (lowercircle)       [below=of maintopic] {4};

%Lines
\draw[->] (uppercircle.south) -- (maintopic.north);
\draw[->] (maintopic.east) -- (rightsquare.west);
\draw[->] (rightsquare.south) .. controls +(down:7mm) and +(right:7mm) .. (lowercircle.east);
\end{tikzpicture}
\end{document}
```

[이 예제를 Overleaf에서 열기](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=More+advanced+TikZ+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Btikz%7D%0A%5Cusetikzlibrary%7Bpositioning%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Btikzpicture%7D%5B%0Aroundnode%2F.style%3D%7Bcircle%2C+draw%3Dgreen%2160%2C+fill%3Dgreen%215%2C+very+thick%2C+minimum+size%3D7mm%7D%2C%0Asquarednode%2F.style%3D%7Brectangle%2C+draw%3Dred%2160%2C+fill%3Dred%215%2C+very+thick%2C+minimum+size%3D5mm%7D%2C%0A%5D%0A%25Nodes%0A%5Cnode%5Bsquarednode%5D++++++%28maintopic%29++++++++++++++++++++++++++++++%7B2%7D%3B%0A%5Cnode%5Broundnode%5D++++++++%28uppercircle%29+++++++%5Babove%3Dof+maintopic%5D+%7B1%7D%3B%0A%5Cnode%5Bsquarednode%5D++++++%28rightsquare%29+++++++%5Bright%3Dof+maintopic%5D+%7B3%7D%3B%0A%5Cnode%5Broundnode%5D++++++++%28lowercircle%29+++++++%5Bbelow%3Dof+maintopic%5D+%7B4%7D%3B%0A%0A%25Lines%0A%5Cdraw%5B-%3E%5D+%28uppercircle.south%29+--+%28maintopic.north%29%3B%0A%5Cdraw%5B-%3E%5D+%28maintopic.east%29+--+%28rightsquare.west%29%3B%0A%5Cdraw%5B-%3E%5D+%28rightsquare.south%29+..+controls+%2B%28down%3A7mm%29+and+%2B%28right%3A7mm%29+..+%28lowercircle.east%29%3B%0A%5Cend%7Btikzpicture%7D%0A%5Cend%7Bdocument%7D)

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

![OLV2tikz5.png](/files/11106ee3c9fe6691cbfeb70fc4c0a96969efd89d)

이 그림에는 본질적으로 세 가지 명령이 있습니다: 노드 정의, 노드 선언, 그리고 두 노드를 연결하는 선입니다.

* **`roundnode/.style={circle, draw=green!60, fill=green!5, very thick, minimum size=7mm}`**: 다음의 매개변수로 전달됩니다 `tikzpicture` 환경. 이는 다음으로 참조될 노드를 정의합니다 `roundnode`: 이 노드는 바깥 테두리가 `green!60` 색상으로 그려지고 `green!5`으로 채워지는 원이 됩니다. 선 두께는 `very thick` 와 그 `minimum size` 는 `7mm`입니다. 이 아래 줄은 `squarednode`라는 두 번째 직사각형 모양의 노드를 비슷한 매개변수로 정의합니다.
* **`\node[squarednode] (maintopic) {2};`**: 이는 이전 명령에서 정의한 대로 `squarednode`를 생성합니다. 이 노드의 ID는 `maintopic` 이며 숫자 `2`를 포함합니다. 중괄호 안을 비워 두면 텍스트가 표시되지 않습니다.
* **`[above=of maintopic]`**: 첫 번째 노드를 제외한 모든 노드에는 다른 노드에 대한 상대적 위치를 결정하는 추가 매개변수가 있다는 점에 주의하세요. 예를 들어, `[above=of maintopic]` 은 이 노드가 이름이 `maintopic`인 노드 위에 나타나야 함을 의미합니다. 이 위치 지정 시스템을 사용하려면 `\usetikzlibrary{positioning}` 를 서문에 추가해야 합니다. 다음이 없으면 `positioning` 라이브러리에서는 다음 구문을 사용할 수 있습니다 `above of=maintopic` 대신 사용할 수 있지만, `positioning` 구문이 더 유연하고 강력합니다. 다음과 같이 확장할 수 있습니다 `above=**3cm** of maintopic` 즉, 실제 거리 `maintopic`.
* **`\draw[->] (uppercircle.south) -- (maintopic.north);`**: 화살표처럼 생긴 직선이 그려집니다. 이 구문은 이미 [기본 요소](#basic-elements-points-lines-and-paths) 섹션에서 설명했습니다. 유일한 차이점은 선의 끝점을 쓰는 방식입니다: 노드(그래서 노드에 이름을 붙였습니다)와 노드에 대한 상대적 위치를 참조합니다.

## 참조 가이드

에서 사용할 수 있는 색상 및 두께 매개변수 `tikz` 패키지를 불러올 때 추가하세요:

| 매개변수 | 값                                                           | picture                                                              |
| ---- | ----------------------------------------------------------- | -------------------------------------------------------------------- |
| 색상을  | white, black, red, green, blue, cyan, magenta, yellow       | ![BasicColours.png](/files/54c05b70fddf13447529d9746f2b428bb8579e20) |
| 두께   | ultra thin, very thin, thin, thick, very thick, ultra thick | ![Thickness.png](/files/3feeef67b055a44f902561e625477d725dde1cfa)    |

LaTeX 배포판에 더 많은 색상이 포함되어 있을 수 있습니다. 다음을 참조하세요 [LaTeX에서 색상 사용](/latex/ko/formatting/13-using-colors-in-latex.md)

## 추가 읽을거리

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

* [LaTeX에서 색상 사용](/latex/ko/formatting/13-using-colors-in-latex.md)
* [Pgfplots 패키지](/latex/ko/field-specific/08-pgfplots-package.md)
* [이미지 삽입](/latex/ko/more-topics/27-inserting-images.md)
* [표와 그림 목록](/latex/ko/figures-and-tables/03-lists-of-tables-and-figures.md)
* [이미지와 표 배치하기](/latex/ko/figures-and-tables/02-positioning-images-and-tables.md)
* [LaTeX에서 직접 다이어그램 그리기](/latex/ko/figures-and-tables/04-picture-environment.md)
* [TikZ 및 PGF 패키지 매뉴얼](http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf)
* [TeXample.net의 TikZ 및 PGF 예제](http://www.texample.net/tikz/examples/all/)


---

# 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/figures-and-tables/05-tikz-package.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.
