iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📃
Solving URL Line Break Issues in Pandoc
Problem
The URL overflows horizontally like this. I wrote the URLs directly because it was a quick way to display them in a PDF.

Solution
---
header-includes:
- \usepackage{xurl}
---
\url{https://exmaple.com/longlonglonglonglonglong/long/}
Writing it as \url{xxx} while using xurl as shown above ensures it is processed correctly as a URL.
pandoc input.md -o out.pdf --pdf-engine=lualatex
So that it fits.

The above settings are likely the bare minimum, but since my actual configuration includes other settings, I'll provide the full configuration just in case.
---
title: "repo"
author: "uliboooo"
date: \today
documentclass: ltjsarticle
classoption: a4paper
geometry:
- margin=2.5cm
pdf-engine: lualatex
header-includes:
- \usepackage[no-math, no-prompts]{luatexja-fontspec}
- \usepackage{xurl}
- \interfootnotelinepenalty=10000
- \usepackage{endnotes}
- \let\footnote=\endnote
---
The command remains the same.
Why does this happen?
I don't know the details very well, but it seems that because % serves as a comment starter or some other command in the TeX processing system, options like line-wrapping were being ignored.
Discussion