> 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/in-depth-articles/27-how-to-use-latexdiff-on-overleaf.md).

# Overleaf에서 latexdiff를 사용하는 방법

이 글에서는 사용하는 두 가지 방법을 보여줍니다 [latexdiff](https://ctan.org/pkg/latexdiff?lang=en) Overleaf에서.

## latexdiff란?

`latexdiff` 두 개의 LaTeX 파일 내용을 비교하도록 설계된 Perl 스크립트입니다. 이 스크립트는 해당 파일들 사이의 중요한 차이점을 시각적으로 표시하는 LaTeX 코드를 생성합니다.

비교하려면 `new.tex` 와 `old.tex` 을 비교하고 결과를 다음 이름의 파일로 출력하려면 `diff.tex`, 다음과 같이 사용합니다: `latexdiff` 다음과 같이:

```
latexdiff OPTIONS old.tex new.tex > diff.tex
```

`OPTIONS` 는 latexdiff의 동작을 구성하는 데 사용할 수 있는 명령줄 매개변수입니다 `latexdiff`동작에 대해—다음을 참조하세요 [`latexdiff` 설명서](http://mirrors.ctan.org/support/latexdiff/doc/latexdiff-man.pdf) 에서 사용 가능한 옵션 목록을 확인하세요.

## Overleaf에서 latexdiff를 사용하는 방법

두 가지 해결책을 제공합니다. 둘 다 tex.stackexchange에 게시되어 논의되었습니다. 그 [첫 번째 방법](#david-carlisles-solution) 는 [David Carlisle가 제안했습니다](https://tex.stackexchange.com/a/603311), 그리고 [두 번째 해결책](#tom-hejdas-solution) 는 [Tom Hejda가 제안했습니다](https://tex.stackexchange.com/a/603351), Overleaf 지원 매니저입니다.

### David Carlisle의 해결책

이 해결책을 보여 주는 소스 파일은 아래에 나열되어 있으며, Overleaf 프로젝트로 열 수 있는 링크도 함께 제공됩니다. 참조 [이 첫 번째 해결책이 작동하는 방식](#how-this-first-solution-works) 이 코드에 대한 간단한 설명으로.

[Overleaf에서 David Carlisle의 해결책을 엽니다.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name\[]=main.tex\&snip\[]=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7BDavid+Carlisle%27s+solution%7D%0A%5Cauthor%7Bme%7D%0A%5Cdate%7BMay+2024%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Csection%7BIntroduction%7D%0Azzz%0A%5Cend%7Bdocument%7D\&snip_name\[]=main2.tex\&snip\[]=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7Blatexdiff%7D%0A%5Cauthor%7Bme%5Cand+you%7D%0A%5Cdate%7BMay+2023%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cmaketitle%0A%0A%5Csection%7BIntroduction%7D%0Azzz+zzz%0A%0A%5Csection%7BSection%7D%0Azzz%0A%5Cend%7Bdocument%7D\&snip_name\[]=latexmkrc\&snip\[]=%24pdflatex+%3D+%22latexdiff+main.tex+main2.tex+%3E+main-d.tex%3B+pdflatex+%25O++main-d%22\&main_document=main.tex)

**main.tex**

```latex
\documentclass{article}
\title{David Carlisle's solution}
\author{me}
\date{May 2024}
\begin{document}
\maketitle
\section{Introduction}
zzz
\end{document}
```

**main2.tex**

```latex
\documentclass{article}
\title{latexdiff}
\author{me\and you}
\date{May 2023}

\begin{document}

\maketitle

\section{Introduction}
zzz zzz

\section{Section}
zzz
\end{document}
```

**latexmkrc**

```latex
$pdflatex = "latexdiff main.tex main2.tex > main-d.tex; pdflatex %O  main-d"
```

[Overleaf에서 David Carlisle의 해결책을 엽니다.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name\[]=main.tex\&snip\[]=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7BDavid+Carlisle%27s+solution%7D%0A%5Cauthor%7Bme%7D%0A%5Cdate%7BMay+2024%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Csection%7BIntroduction%7D%0Azzz%0A%5Cend%7Bdocument%7D\&snip_name\[]=main2.tex\&snip\[]=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7Blatexdiff%7D%0A%5Cauthor%7Bme%5Cand+you%7D%0A%5Cdate%7BMay+2023%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cmaketitle%0A%0A%5Csection%7BIntroduction%7D%0Azzz+zzz%0A%0A%5Csection%7BSection%7D%0Azzz%0A%5Cend%7Bdocument%7D\&snip_name\[]=latexmkrc\&snip\[]=%24pdflatex+%3D+%22latexdiff+main.tex+main2.tex+%3E+main-d.tex%3B+pdflatex+%25O++main-d%22\&main_document=main.tex)

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

![latexdiff가 생성한 출력의 그래픽](/files/e1fa920c2b004973bfce9c482f39fa523c0ea32e)

#### 이 첫 번째 해결책이 작동하는 방식

이 해결책은 파일들을 비교합니다 `main.tex` 및 `main2.tex` 그리고 결과를 다음 이름의 파일에 씁니다 `main-d.tex`. 주의하세요, 왜냐하면 `main-d.tex` 파일은 *생성된* 파일, 즉 우리의 코드로 생성된 파일이므로 프로젝트의 파일 목록에는 표시되지 않습니다.

다음 이름의 파일을 사용하여 작동합니다 `latexmkrc` 이 파일에는 Overleaf의 컴파일 과정을 사용자 지정하는 Perl 코드가 들어 있습니다. 여기서는 pdfLaTeX로 컴파일하는 명령이 먼저 다음을 실행하도록 다시 정의됩니다 `latexdiff` 그런 다음 pdfLaTeX를 실행하여 다음을 컴파일합니다 `main-d.tex`, 다음에 의해 생성된 파일 `latexdiff`.

처럼 [해결책의 저자가 언급했듯이](https://tex.stackexchange.com/a/603311), 실행을 중지하려면 `latexdiff` 그리고 다음의 실제 내용을 조판하려면 `main.tex` 또는 `main2.tex`, 다음을 추가하기만 하면 됩니다 `#`, Perl 주석 표시자인 #를 `latexmkrc` 명령줄에 추가하면 다음과 같이 됩니다:

```
# $pdflatex = "latexdiff main.tex main2.tex > main-d.tex; pdflatex %O  main-d"
```

이제 다음을 컴파일할 수 있습니다 `main.tex` 또는 `main2.tex` 두 파일의 실제 내용을 조판할 수 있으며, 서로의 차이점이 아닙니다.

자세한 내용은 Overleaf 문서를 참조하세요 [사용하는 방법 `latexmkrc` Overleaf에서](/latex/ko/in-depth-articles/28-how-to-use-latexmkrc-with-overleaf.md).

### Tom Hejda의 해결책

이 해결책을 보여 주는 소스 파일은 아래에 나열되어 있으며, Overleaf 프로젝트로 열 수 있는 링크도 함께 제공됩니다. 참조 [이 두 번째 해결책이 작동하는 방식](#how-this-second-solution-works) 이 코드에 대한 간단한 설명으로.

[Overleaf에서 Tom Hejda의 해결책을 엽니다.](https://www.overleaf.com/docs?engine=\&snip_name\[]=diff.tex\&snip\[]=%5CRequirePackage%7Bshellesc%7D%0A%5CShellEscape%7Blatexdiff+main.tex+main2.tex+%3E+main-d.tex%7D%0A%5Cinput%7Bmain-d%7D%0A%5Cdocumentclass%7Bdummy%7D%0A%5Ctitle%7BDemonstrating+latexdiff%7D\&snip_name\[]=main.tex\&snip\[]=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7BTom+Hejda%27s+solution%7D%0A%5Cauthor%7Bme%7D%0A%5Cdate%7BMay+2024%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Csection%7BIntroduction%7D%0Azzz%0A%5Cend%7Bdocument%7D\&snip_name\[]=main2.tex\&snip\[]=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7Blatexdiff%7D%0A%5Cauthor%7Bme%5Cand+you%7D%0A%5Cdate%7BMay+2023%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cmaketitle%0A%0A%5Csection%7BIntroduction%7D%0Azzz+zzz%0A%0A%5Csection%7BSection%7D%0Azzz%0A%5Cend%7Bdocument%7D\&main_document=diff.tex)

**diff.tex**

```latex
\RequirePackage{shellesc}
\ShellEscape{latexdiff main.tex main2.tex > main-d.tex}
\input{main-d}
\documentclass{dummy}
\title{Demonstrating latexdiff}
```

**main.tex**

```latex
\documentclass{article}
\title{Tom Hejda's solution}
\author{me}
\date{May 2024}
\begin{document}
\maketitle
\section{Introduction}
zzz
\end{document}
```

**main2.tex**

```latex
\documentclass{article}
\title{latexdiff}
\author{me\and you}
\date{May 2023}

\begin{document}

\maketitle

\section{Introduction}
zzz zzz

\section{Section}
zzz
\end{document}
```

[Overleaf에서 Tom Hejda의 해결책을 엽니다.](https://www.overleaf.com/docs?engine=\&snip_name\[]=diff.tex\&snip\[]=%5CRequirePackage%7Bshellesc%7D%0A%5CShellEscape%7Blatexdiff+main.tex+main2.tex+%3E+main-d.tex%7D%0A%5Cinput%7Bmain-d%7D%0A%5Cdocumentclass%7Bdummy%7D%0A%5Ctitle%7BDemonstrating+latexdiff%7D\&snip_name\[]=main.tex\&snip\[]=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7BTom+Hejda%27s+solution%7D%0A%5Cauthor%7Bme%7D%0A%5Cdate%7BMay+2024%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Csection%7BIntroduction%7D%0Azzz%0A%5Cend%7Bdocument%7D\&snip_name\[]=main2.tex\&snip\[]=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7Blatexdiff%7D%0A%5Cauthor%7Bme%5Cand+you%7D%0A%5Cdate%7BMay+2023%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cmaketitle%0A%0A%5Csection%7BIntroduction%7D%0Azzz+zzz%0A%0A%5Csection%7BSection%7D%0Azzz%0A%5Cend%7Bdocument%7D\&main_document=diff.tex)

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

![latexdiff가 생성한 출력의 그래픽](/files/ebbe81dc662b71f2dc01637934300210a88ac0dc)

#### 이 두 번째 해결책이 작동하는 방식

이 해결책은 파일들을 비교합니다 `main.tex` 및 `main2.tex` 그리고 결과를 다음 이름의 파일에 씁니다 `main-d.tex`. 주의하세요, 왜냐하면 `main-d.tex` 파일은 *생성된* 파일, 즉 우리의 코드로 생성된 파일이므로 프로젝트의 파일 목록에는 표시되지 않습니다.

다음 이름의 파일은 `diff.tex` 다음을 사용합니다 `\ShellEscape` 명령은 다음에서 제공되며 [`shellesc` 패키지](https://ctan.org/pkg/shellesc?lang=en), 이를 실행하기 위해 `latexdiff`. 비교 결과는 다음에 포함되어 있으며 `main-d.tex`, 다음과 같이 `\input` 에 `diff.tex` 조판에 사용됩니다.

`diff.tex` 다음 줄이 포함되어 있습니다 `\documentclass{dummy}` Overleaf의 컴파일러가 다음을 믿도록 속이기 위해 `diff.tex` 를 컴파일할 수 있습니다. 이는 Overleaf의 컴파일 과정이 현재 열려 있는 파일에서 다음의 존재 여부를 확인하기 때문에 작동합니다 `\documentclass`. 찾지 못하면 Overleaf는 메뉴에 Main으로 나열된 파일을 컴파일합니다 **메인** 파일.

선택하면 **다시 컴파일** 와 `diff.tex` 편집기에서 열기, 비교 결과를 조판합니다. 다음을 선택하고 컴파일할 수 있습니다 `main.tex` 또는 `main2.tex` 둘 다 다음을 포함하고 있기 때문에 `\documentclass` 명령을 어떻게 해석해야 하는지 알게 되므로 오류 메시지가 사라집니다.

에 대한 자세한 내용은 `latexdiff` 다음을 확인하세요 [공식 문서](http://mirrors.ctan.org/support/latexdiff/doc/latexdiff-man.pdf).


---

# 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/in-depth-articles/27-how-to-use-latexdiff-on-overleaf.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.
