코딩 연습

챕터별로 tex 파일 만들고 컴파일하기 본문

LaTeX

챕터별로 tex 파일 만들고 컴파일하기

코딩아저씨 2025. 9. 10. 00:40
반응형

 

 

latex 로 책을 만들 때, chap1.tex, chap2.tex, chap3.tex 로 tex 파일을 만들고 이 파일들을 book.tex 파일에서 하나로 합치는 구조로 작업을 하고 싶다면 다음과 같이 하면 된다.

 

book.tex 파일은 아래와 같아야 한다.

\documentclass{book}
\usepackage{subfiles}

\begin{document}

\tableofcontents

\subfile{chap1.tex}
\subfile{chap2.tex}
\subfile{chap3.tex}

\end{document}

 

chap1.tex 파일은 다음과 같아야 한다.

\documentclass[book.tex]{subfiles}

\begin{document}
\chapter{첫 번째 장}
여기에 chap1 내용이 들어갑니다.
\end{document}

 

이렇게 하면 book.tex 를 커파일하면 전체 책이 나오고

chap1.tex 만 컴파일하면 chap1 단독 PDFㅏ 나오게 된다.

반응형


Comments