> 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/id/artikel-mendalam/27-how-to-use-latexdiff-on-overleaf.md).

# Cara menggunakan latexdiff di Overleaf

Artikel ini menunjukkan dua cara untuk menggunakan [latexdiff](https://ctan.org/pkg/latexdiff?lang=en) di Overleaf.

## Apa itu latexdiff?

`latexdiff` adalah skrip Perl yang dirancang untuk membandingkan isi dua berkas LaTeX. Skrip ini menghasilkan kode LaTeX yang secara visual menampilkan perbedaan signifikan antara berkas-berkas tersebut.

Untuk membandingkan `new.tex` dengan `old.tex` dan mengeluarkan hasilnya ke berkas bernama `diff.tex`, Anda dapat menggunakan `latexdiff` seperti ini:

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

`OPTIONS` adalah parameter baris perintah yang dapat Anda gunakan untuk mengonfigurasi `latexdiff`perilakunya—lihat [`latexdiff` dokumentasi](http://mirrors.ctan.org/support/latexdiff/doc/latexdiff-man.pdf) untuk daftar opsi yang tersedia.

## Cara menggunakan latexdiff di Overleaf

Kami menyediakan dua solusi, keduanya dipublikasikan dan dibahas di tex.stackexchage.  [metode pertama](#david-carlisles-solution) diusulkan [oleh David Carisle](https://tex.stackexchange.com/a/603311),  [solusi kedua](#tom-hejdas-solution) diusulkan [diusulkan oleh Tom Hejda](https://tex.stackexchange.com/a/603351), Manajer Dukungan Overleaf.

### Solusi David Carlisle

Berkas sumber untuk mendemonstrasikan solusi ini tercantum di bawah, bersama dengan tautan untuk membukanya sebagai proyek Overleaf. Lihat [Cara kerja solusi pertama ini](#how-this-first-solution-works) untuk penjelasan singkat tentang kode ini.

[Buka solusi David Carlisle di Overleaf.](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{Solusi David Carlisle}
\author{saya}
\date{Mei 2024}
\begin{document}
\maketitle
\section{Pendahuluan}
zzz
\end{document}
```

**main2.tex**

```latex
\documentclass{article}
\title{latexdiff}
\author{saya\and Anda}
\date{Mei 2023}

\begin{document}

\maketitle

\section{Pendahuluan}
zzz zzz

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

**latexmkrc**

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

[Buka solusi David Carlisle di Overleaf.](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)

Contoh ini menghasilkan keluaran berikut:

![Grafik yang menunjukkan output yang dihasilkan oleh latexdiff](/files/a0c7ffdbd68116d1ae8e421e4a7bf61e60c14b64)

#### Cara kerja solusi pertama ini

Solusi ini membandingkan berkas `main.tex` dan `main2.tex` dan menulis hasilnya ke berkas bernama `main-d.tex`. Perhatikan bahwa karena `main-d.tex` berkas *yang dihasilkan* adalah berkas yang dibuat, yaitu dibuat oleh kode kami, berkas tersebut tidak akan terlihat (tercantum) di dalam berkas proyek.

Ini bekerja dengan memanfaatkan berkas bernama `latexmkrc` yang berisi kode Perl untuk menyesuaikan proses kompilasi Overleaf. Di sini, perintah untuk mengompilasi menggunakan pdfLaTeX didefinisikan ulang untuk pertama-tama menjalankan `latexdiff` lalu menjalankan pdfLaTeX untuk mengompilasi `main-d.tex`, berkas yang dihasilkan oleh `latexdiff`.

Sebagaimana [dicatat oleh penulis solusi](https://tex.stackexchange.com/a/603311), untuk menghentikan menjalankan `latexdiff` dan menata konten sebenarnya dari `main.tex` atau `main2.tex`, cukup tambahkan sebuah `#`, penanda komentar Perl, ke `latexmkrc` baris perintah, sehingga terlihat seperti ini:

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

Sekarang Anda dapat mengompilasi `main.tex` atau `main2.tex` untuk menata konten aslinya, bukan perbedaan di antara keduanya.

Untuk informasi lebih lanjut, lihat artikel Overleaf [Cara menggunakan `latexmkrc` dengan Overleaf](/latex/id/artikel-mendalam/28-how-to-use-latexmkrc-with-overleaf.md).

### Solusi Tom Hejda

Berkas sumber untuk mendemonstrasikan solusi ini tercantum di bawah, bersama dengan tautan untuk membukanya sebagai proyek Overleaf. Lihat [Cara kerja solusi kedua ini](#how-this-second-solution-works) untuk penjelasan singkat tentang kode ini.

[Buka solusi Tom Hejda di Overleaf.](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{Mendemonstrasikan latexdiff}
```

**main.tex**

```latex
\documentclass{article}
\title{Solusi Tom Hejda}
\author{saya}
\date{Mei 2024}
\begin{document}
\maketitle
\section{Pendahuluan}
zzz
\end{document}
```

**main2.tex**

```latex
\documentclass{article}
\title{latexdiff}
\author{saya\and Anda}
\date{Mei 2023}

\begin{document}

\maketitle

\section{Pendahuluan}
zzz zzz

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

[Buka solusi Tom Hejda di Overleaf.](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)

Contoh ini menghasilkan keluaran berikut:

![Grafik yang menunjukkan output yang dihasilkan oleh latexdiff](/files/6db0b98665912fb43a3d0e364b41c1bb8300c140)

#### Cara kerja solusi kedua ini

Solusi ini membandingkan berkas `main.tex` dan `main2.tex` dan menulis hasilnya ke berkas bernama `main-d.tex`. Perhatikan bahwa karena `main-d.tex` berkas *yang dihasilkan* adalah berkas yang dibuat, yaitu dibuat oleh kode kami, berkas tersebut tidak akan terlihat (tercantum) di dalam berkas proyek.

Sebuah berkas bernama `diff.tex` menggunakan `\ShellEscape` perintah, yang disediakan oleh [`shellesc` ke preambel dokumen Anda (seperti disarankan](https://ctan.org/pkg/shellesc?lang=en), untuk menjalankan `latexdiff`. Hasil perbandingan, yang terdapat dalam `main-d.tex`, `\input` ke `diff.tex` untuk penataan.

`diff.tex` berisi baris `\documentclass{dummy}` untuk mengakali kompilator Overleaf agar percaya `diff.tex` dapat dikompilasi. Itu berhasil karena proses kompilasi Overleaf memeriksa berkas yang sedang dibuka saat ini untuk keberadaan `\documentclass`. Jika tidak menemukannya, Overleaf mengompilasi berkas yang tercantum di Menu sebagai **Utama** .

Jika Anda memilih **Kompilasi ulang** dengan `diff.tex` buka di editor, itu akan menata hasil perbandingan. Anda dapat memilih dan mengompilasi `main.tex` atau `main2.tex` karena keduanya berisi sebuah `\documentclass` perintah.

Untuk informasi lebih lanjut tentang `latexdiff` lihat [dokumentasi resmi](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/id/artikel-mendalam/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.
