% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
  10pt,twoside,
  spanish,
  a6paper,
]{book}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
  \usepackage{amssymb}
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
  \setmainfont[]{Alegreya Sans}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
  pdftitle={Proteger la vida y la libertad},
  pdfauthor={Nicky Case},
  pdflang={es},
  hidelinks,
  pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[hcentering,bindingoffset=0.75cm,bmargin=1cm,tmargin=1cm,rmargin=1.5cm,lmargin=1cm,includefoot,includehead,headsep=10pt,footskip=20pt]{geometry}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
% Make links footnotes instead of hotlinks:
\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
%\usepackage{quotchap} % changes style of chapter headings
\usepackage{setspace}
\usepackage{fancyhdr}

\newcommand{\copyleft}{\reflectbox{©}}

%\definecolor{grey}{cmyk}{0,0,0,0.6}
%\definecolor{white}{cmyk}{0,0,0,0}

%\renewcommand{\chapnumfont}{\color{white}}

\pagestyle{fancy}
\fancyheadoffset{0pt}
\fancyhead[]{}
\fancyhead[LE]{\footnotesize{\leftmark}}
\fancyhead[RO]{}
\fancyfoot[C]{\footnotesize{\thepage}}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

% Por alguna razón pandoc lo pone en 0
\setlength{\parindent}{15pt}

% Cortar por cualquier lado, lo encontré en texexchange
\expandafter\def\expandafter\UrlBreaks\expandafter{\UrlBreaks%  save the current one
\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
\do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D%
\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N%
\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X%
\do\Y\do\Z}

% No mostrar los copetes en las imágenes
\usepackage[labelformat=empty]{caption}

% Poner la autora en el título
%
% Para esto el título del capítulo tiene que tener el formato "Título.
% Autora"
%
% https://stackoverflow.com/a/1507530
%\usepackage{substr}
\usepackage[explicit,raggedright]{titlesec}
\titleformat{\chapter}[hang]{}{}{0cm}{%
  \raggedleft
  \raggedright
  \Huge\BeforeSubString{ --- }{#1}\\
  \IfSubStringInString{ --- }{#1}{%
  {\Large\itshape\BehindSubString{ --- }{#1}}%
}}

% https://tex.stackexchange.com/a/233271
% resuelve https://github.com/jgm/pandoc/issues/1632 y además no muestra
% guiones vacíos como con el substring anterior
\titleformat{name=\chapter,numberless}[hang]{}{}{0cm}{%
  \raggedright\Huge #1\markboth{#1}{#1}%
}

\raggedbottom
\widowpenalty=10000
\clubpenalty=10000

% eliminar los headers de las paginas que quedan vacias!
\usepackage{emptypage}
% re-definir \includegraphics para que todas las imagenes esten a sangre
% en una pagina aparte
\usepackage{eso-pic}
\let\latexincludegraphics\includegraphics
\renewcommand{\includegraphics}[2][]{%
  \newpage
  \thispagestyle{empty}
  \null
  \AddToShipoutPicture*{%
    \put(0,0){\latexincludegraphics[width=\paperwidth,height=\paperheight]{#2}}}
  \newpage
}
\ifxetex
  % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
  \usepackage{polyglossia}
  \setmainlanguage[]{spanish}
\else
  \usepackage[shorthands=off,main=spanish]{babel}
\fi
\ifluatex
  \usepackage{selnolig}  % disable illegal ligatures
\fi

\title{Proteger la vida y la libertad}
\author{Nicky Case}
\date{}

\begin{document}
\frontmatter
\maketitle

\newpage
\thispagestyle{empty}

\begin{flushleft}\hbox{\Large{Utopía Pirata}}
\copyleft \, \the\year\space -- Partido Interdimensional Pirata
\url{https://utopia.partidopirata.com.ar}

\vfill

\centering
\latexincludegraphics[width=3cm]{assets/images/la_copia_comparte_cultura.png}

Esta edición se libera bajo la Licencia de Producción de Pares.

\footnotesize{\url{https://endefensadelsl.org/ppl_deed_es.html}}

\end{flushleft}
\newpage

{
\setcounter{tocdepth}{2}
\tableofcontents
}
\mainmatter
\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0001.png}
\caption{La vida y la libertad 1}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0002.png}
\caption{La vida y la libertad 2}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0003.png}
\caption{La vida y la libertad 3}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0004.png}
\caption{La vida y la libertad 4}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0005.png}
\caption{La vida y la libertad 5}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0006.png}
\caption{La vida y la libertad 6}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0007.png}
\caption{La vida y la libertad 7}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0008.png}
\caption{La vida y la libertad 8}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0009.png}
\caption{La vida y la libertad 9}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0010.png}
\caption{La vida y la libertad 10}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0011.png}
\caption{La vida y la libertad 11}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0012.png}
\caption{La vida y la libertad 12}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0013.png}
\caption{La vida y la libertad 13}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0014.png}
\caption{La vida y la libertad 14}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0015.png}
\caption{La vida y la libertad 15}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0016.png}
\caption{La vida y la libertad 16}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0017.png}
\caption{La vida y la libertad 17}
\end{figure}

\begin{figure}
\centering
\includegraphics{assets/images/la_vida_y_la_libertad/panel0018.png}
\caption{La vida y la libertad 18}
\end{figure}

\backmatter
\end{document}
