From b54fa9e1f0115d4caa8cf3187cccf891c6a5e807 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Thu, 11 Feb 2021 20:48:16 +1100 Subject: [PATCH] Allow line breaks in URLs in PDFs --- conf.py | 2 +- preamble.tex.txt | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/conf.py b/conf.py index 5f63fc3..2490d4b 100644 --- a/conf.py +++ b/conf.py @@ -22,7 +22,7 @@ copyright = '2021 Lee Yingtong Li' author = 'Lee Yingtong Li' # The full version, including alpha/beta/rc tags -release = '0.2' +release = '0.2.1-dev' version = release diff --git a/preamble.tex.txt b/preamble.tex.txt index 29cf1c7..23f09a7 100644 --- a/preamble.tex.txt +++ b/preamble.tex.txt @@ -1,3 +1,5 @@ +\makeatletter + % Typographic improvements \usepackage{microtype} @@ -9,6 +11,14 @@ \def\sphinxstyleindexentry#1{#1} % no monospaced index entries \def\sphinxstyleindexextra#1{ (#1)} % no italics +% Allow line breaks in URLs +\usepackage{seqsplit} +\protected\def\sphinxurl#1{{% + \sphinxunactivateextrasandspace % + \endlinechar\m@ne\everyeof{}% + \scantokens{\href{#1}{\seqsplit{#1}}}% +}} + % Fonts \setmainfont{EB Garamond} %\setsansfont{IBM Plex Sans}[BoldFont={* Medium},BoldItalicFont={* Medium Italic}] @@ -32,14 +42,12 @@ \setlength{\footnotemargin}{0.4cm} % Header/footer style -\makeatletter \fancypagestyle{normal}{ \fancyhead[RO,LE]{} \fancyfoot[RO]{{\footnotesize\py@HeaderFamily\nouppercase{\leftmark} | \thepage}} \fancyfoot[LE]{{\footnotesize\py@HeaderFamily\thepage}} %\renewcommand{\headrulewidth}{0.4pt} } -\makeatother % Back of title page content \newcommand{\sphinxbackoftitlepage}{ @@ -75,7 +83,6 @@ % Override Sphinx title page \usepackage[iso]{isodate} -\makeatletter \renewcommand{\sphinxmaketitle}{% \let\sphinxrestorepageanchorsetting\relax \ifHy@pageanchor\def\sphinxrestorepageanchorsetting{\Hy@pageanchortrue}\fi @@ -117,4 +124,5 @@ \if@openright\cleardoublepage\else\clearpage\fi \sphinxrestorepageanchorsetting } + \makeatother