1

I want to put a line break for the urls as it exceeds the page margin. I've refereed couple of posts on StackExhange but still it's not successful. The error for the following code says !LaTeX Error: Option clash for package hyperref.

Any help in resolving this is much appreciated.

\documentclass[11pt, a4paper]{article}
\usepackage{geometry}
\usepackage[inner=1.5cm,outer=1.5cm,top=2.5cm,bottom=2.5cm]{geometry}
\pagestyle{empty}
\usepackage{graphicx}
\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}
\usepackage{url}


\usepackage{fancyhdr, lastpage, bbding, pmboxdraw}
\usepackage[usenames,dvipsnames]{color}
\definecolor{darkblue}{rgb}{0,0,.6}
\definecolor{darkred}{rgb}{.7,0,0}
\definecolor{darkgreen}{rgb}{0,.6,0}
\definecolor{red}{rgb}{.98,0,0}
\usepackage[colorlinks,pagebackref,pdfusetitle,urlcolor=darkblue,citecolor=darkblue,linkcolor=darkred,bookmarksnumbered,plainpages=false]{hyperref}
%\renewcommand{\thefootnote}{\fnsymbol{footnote}}



\pagestyle{fancyplain}
\fancyhf{}
\lhead{ \fancyplain{}{Course Name} }
%\chead{ \fancyplain{}{} }
\rhead{ \fancyplain{}{\today} }
%\rfoot{\fancyplain{}{page \thepage\ of \pageref{LastPage}}}
\fancyfoot[RO, LE] {page \thepage\ of \pageref{LastPage} }
\thispagestyle{plain}



%%%%%%%%%%%% LISTING %%%
\usepackage{listings}
\usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
\usepackage{verbatim} % used to display code
\usepackage{fancyvrb}
\usepackage{acronym}
\usepackage{amsthm}
\VerbatimFootnotes % Required, otherwise verbatim does not work in footnotes!



\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}
\definecolor{CadetBlue}{cmyk}{0.62,0.57,0.23,0}
\definecolor{lightlightgray}{gray}{0.93}



\lstset{
%language=bash,                          % Code langugage
basicstyle=\ttfamily,                   % Code font, Examples: \footnotesize, \ttfamily
keywordstyle=\color{OliveGreen},        % Keywords font ('*' = uppercase)
commentstyle=\color{gray},              % Comments font
numbers=left,                           % Line nums position
numberstyle=\tiny,                      % Line-numbers fonts
stepnumber=1,                           % Step between two line-numbers
numbersep=5pt,                          % How far are line-numbers from code
backgroundcolor=\color{lightlightgray}, % Choose background color
frame=none,                             % A frame around the code
tabsize=2,                              % Default tab size
captionpos=t,                           % Caption-position = bottom
breaklines=true,                        % Automatic line breaking?
breakatwhitespace=false,                % Automatic breaks only at whitespace?
showspaces=false,                       % Dont make spaces visible
showtabs=false,                         % Dont make tabls visible
columns=flexible,                       % Column format
morekeywords={__global__, __device__},  % CUDA specific keywords
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{center}
{\Large \textsc{Modeling and Evaluation}}
\end{center}
\begin{center}
Fall 2014
\end{center}
%\date{September 26, 2014}

\begin{center}
\rule{6in}{0.4pt}
\begin{minipage}[t]{.75\textwidth}
\begin{tabular}{llcccll}
\textbf{Instructor:} & Arman Shokrollahi & & &  & \textbf{Time:} & F 14:00 -- 17:00 \\
\textbf{Email:} &  \href{mailto:XYZ@email.org}{XYZ@email.org} & & & & \textbf{Place:} & 107 Engineering Bldg.
\end{tabular}
\end{minipage}
\rule{6in}{0.4pt}
\end{center}
\vspace{.5cm}
\setlength{\unitlength}{1in}
\renewcommand{\arraystretch}{2}

\noindent\textbf{Main References:}
\begin{enumerate}
\item Kenneth H. Rosen, \textit{Elementary Number Theory and Its Applications}, 6th Edition (2010), Pearson.
\url{https://www.math.upenn.edu/~kazdan/210S19/Notes/crypto/Rosen-Number-Theory-6ed.pdf}
\item David Burton, \textit{Elementary Number Theory}, 7th Edition (2010), McGraw-Hill Education
\url{https://cdchester.co.uk/wp-content/uploads/2018/02/david-m-burton-elementary-number-theory-mcgraw-hill-education-2010.pdf}
\end{enumerate}

\vskip.15in
\noindent\textbf{Office Hours:} After class, or by appointment, or post your questions in the forum provided for this purpose on AeLP.


\end{itemize}
Quantas
  • 101
  • 3
    Welcome! You load hyperref twice. Once without options and then with tons of options. Same for geometry. Also your document ends with \end{itemize}. –  Apr 12 '20 at 04:10
  • Thank you @Schrödinger'scat. I removed the \usepackage{hyperref}, the first one. Still the 2nd url goes beyond the margins. – Quantas Apr 12 '20 at 04:12
  • For a default template, I just added \PassOptionsToPackage{hyphens}{url} \usepackage{hyperref} \usepackage{url} – Quantas Apr 12 '20 at 04:18
  • You can wrap \begin{enumerate} ... \end{enumerate} into \begingroup\sloppy ... \endgroup according to this thread. –  Apr 12 '20 at 04:27
  • @Schrödinger'scat, I removed what I've added and did what you've suggested. It worked ! Thanks a lot. – Quantas Apr 12 '20 at 04:35

0 Answers0