LaTeX에서 TikZ를 사용하여 전문적인 학술 차트를 그리는 방법을 알아봅니다.
TikZ 선택 이유
학술 차트는 정확성과 전문성이 중요합니다. TikZ는 다음과 같은 장점으로 인해 학술 차트 작성에 적합합니다:
- 통합성: LaTeX 문서와 완벽하게 통합되어 일관된 스타일 유지
- 벡터 그래픽: 확대 시에도 품질 손실 없음
- 코드 기반: 간단한 코드로 복잡한 차트 생성 가능
- 다양한 확장성: 다양한 유형의 전문 차트 지원
TikZ 환경 설정
LaTeX 배포판 설치
TikZ를 사용하려면 LaTeX 배포판을 설치해야 합니다:
- Windows: MiKTeX 권장 (자동 패키지 다운로드)
- macOS: MacTeX 설치 (완전한 LaTeX 환경 제공)
- Linux:
sudo apt-get install texlive-full명령어로 설치 가능
TikZ 설치 확인
간단한 LaTeX 문서를 만들어 TikZ가 제대로 작동하는지 확인합니다:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\end{tikzpicture}
\end{document}
PDFLaTeX로 컴파일하면 원이 표시되면 준비 완료입니다.
TikZ 기본 문법
좌표계 및 경로 그리기
TikZ는 카르테시안 좌표계를 사용하며 기본 단위는 cm입니다:
\begin{tikzpicture}[scale=0.8]
% 좌표축 그리기
\draw[->] (-3,0) -- (3,0) node[right] {$x$};
\draw[->] (0,-3) -- (0,3) node[above] {$y$};
% 도형 그리기
\fill[red] (0,0) circle (0.5); % 빨간 점
\draw[blue,thick] (-2,-2) rectangle (2,2); % 파란 사각형
\draw[green,dashed] (0,2) to[out=0,in=90] (2,0); % 곡선
\end{tikzpicture}
색상 및 스타일 설정
다양한 색상과 스타일을 적용할 수 있습니다:
\begin{tikzpicture}
\draw[red, thick, dashed] (0,0) -- (2,0);
\draw[blue, very thick, dotted] (0,1) -- (2,1);
\draw[green!60!black, thin, dash dot] (0,2) -- (2,2);
\end{tikzpicture}
학술 차트 예제
플로우 차트 그리기
플로우 차트는 다음 코드로 쉽게 만들 수 있습니다:
\usetikzlibrary{shapes,arrows}
\begin{tikzpicture}[
proc/.style={rectangle, draw, fill=blue!20,
text width=5em, text centered,
rounded corners, minimum height=4em},
deci/.style={diamond, draw, fill=green!20,
text width=4em, text centered,
aspect=2, minimum height=2em},
arrow/.style={thick,->,>=stealth}
]
% 노드 정의
\node (start) [proc] {시작};
\node (input) [proc, below of=start] {데이터 입력};
\node (deci) [deci, below of=input] {유효?};
\node (process) [proc, below of=deci, yshift=-1cm] {처리};
\node (output) [proc, below of=process] {결과 출력};
\node (end) [proc, below of=output] {종료};
% 화살표 연결
\draw[arrow] (start) -- (input);
\draw[arrow] (input) -- (deci);
\draw[arrow] (deci) -- node[anchor=east] {예} (process);
\draw[arrow] (deci) -- node[anchor=south] {아니오} ++(3,0) |- (input);
\draw[arrow] (process) -- (output);
\draw[arrow] (output) -- (end);
\end{tikzpicture}
데이터 시각화: pgfplots 사용
pgfplots는 TikZ 기반의 강력한 플롯 생성 도구입니다:
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{tikzpicture}
\begin{axis}[
title={실험 데이터 비교},
xlabel={시간 (초)},
ylabel={효율 (\%)},
xmin=0, xmax=10,
ymin=0, ymax=100,
grid=major,
legend pos=outer north east
]
% 함수 선 그리기
\addplot[blue, thick, mark=*] coordinates {
(0, 10) (2, 30) (4, 45) (6, 60) (8, 75) (10, 90)
};
\addlegendentry{방법 A}
% 막대 그래프 그리기
\addplot[ybar, fill=red!30] coordinates {
(1, 25) (3, 40) (5, 55) (7, 70) (9, 85)
};
\addlegendentry{방법 B}
\end{axis}
\end{tikzpicture}
효율적인 도구들
비주얼 에디터
복잡한 차트를 위한 비주얼 에디터:
- TikZiT: 오픈 소스 TikZ 그래픽 에디터
- IPE: LaTeX 공식을 직접 삽입 가능한 벡터 그래픽 에디터
- GeoGebra: 수학 시각화 도구, TikZ 코드로 내보낼 수 있음
코드 생성 도구
기본 TikZ 코드를 자동 생성하는 도구:
- Tables Generator: 온라인 테이블 생성기, TikZ 코드 지원
- matlab2tikz: MATLAB 그래픽을 TikZ 코드로 변환
- tikzplotlib: Matplotlib 그래픽을 TikZ 코드로 변환
학습 자료 추천
- 공식 문서: PGF/TikZ 매뉴얼
- TeXample.net: 다양한 TikZ 예제 모음
- LaTeX 커뮤니티: TeX Stack Exchange 질문 및 답변 자료