1

I had a bibliography item with url that breaks in two line. The break is fine but the box is too wide on the right which there is empty space in the box.

Here is my code

\documentclass[12pt]{article}
\special{papersize=8.5in,11in}

% Packages Section
%=================
\usepackage{amssymb}            % Complex numbers
\usepackage{bbding}             % Symbols
\usepackage{bm}                 % Bold Math
\usepackage{enumerate}
\usepackage{gensymb}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{float}
\usepackage[justification=centering]{caption}
\usepackage[hyphens]{url}
\usepackage[pdftex,breaklinks=true]{hyperref}
\usepackage{listings}
\usepackage{mathtools}
\usepackage[pdftex]{graphicx}
\usepackage{setspace}
\usepackage{subcaption}
\usepackage{textcomp}
\usepackage[usenames, dvipsnames, pdftex]{xcolor}
\usepackage[utf8]{inputenc}     % Support for french language
\usepackage{wordlike}
\usepackage{txfonts}
\usepackage{pgfplots}
\usetikzlibrary{arrows,shadows,positioning}

% Set up Section
%===============

% Page configuration
\pagestyle{fancy}
\fancyhf{}
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{\thepage}

% Remove the header line
\renewcommand{\headrulewidth}{0pt}

% Setup subsection format
\renewcommand\thesubsubsection{\arabic{section}.\arabic{subsection}}

% Setup enumeration
\renewcommand{\labelenumi}{\alph{enumi})}

% Paragraph configuration
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}

% Listing configuration
\definecolor{light-gray}{gray}{0.75}

\newcommand{\me}[1]{\mathrm{\emph{e}}^{#1}}
\newcommand{\jcplx}[0]{\mathrm{\emph{j}}}

% Setup listings
\lstset {
    language=Matlab,
    frame=single,
    backgroundcolor=\color{light-gray},
    breaklines=true,
    basicstyle=\tiny\ttfamily,
    keywordstyle=\bfseries\color{blue!40!black},
    commentstyle=\itshape\color{green!40!black},
    identifierstyle=\color{blue},
    stringstyle=\color{red},
    showstringspaces=false,
    captionpos=t
}

% Text Section
%=============
\begin{document}
    \begin{thebibliography}{9}
        \bibitem{svm}
        Analytics Vidhya : Understanding Support Vector Machine algorithm
        from examples (along with examples),
        \\\url{https://www.analyticsvidhya.com/blog/2017/09/understaing-support-vector-machine-example-code/}
    \end{thebibliography}
\end{document}

Which gives the following:

enter image description here

Is that any way how to make the box stop write just after the url text?

  • In my opinion that box looks horrendous. I always use \usepackage[hidelinks]{hyperref} to make it disappear, or \usepackage[colorlinks]{hyperref} to paint the text instead. – Phelype Oleinik Feb 5 '18 at 0:42
  • Off-topic: The bib entry example you've provided is seriously incomplete, as it's missing information about both the author (Sunil Ray) and the publication date (last updated Sept. 2017). The "author" of this piece is definitely not an entity called "Analytics Vidhya". – Mico Feb 5 '18 at 5:34
  • 1
    If you use wordlike for emulating poor typesetting, you shouldn’t worry about that break. 😉 – egreg Feb 5 '18 at 8:06
4

Your code has a lot of errors I corrected in the following MWE. Important is for exampe the order of calls of packages. In your case that means hyperref should be called last.

I deleted all packages not needed for your problem, but left packages with wrong options to correct them. Please read my comments carefully, marked with <=====.

Your font package txfonts should not be used any more. See for the reasons the infos on ctan. Use \usepackage{newtxtext,newtxmath} instead of \usepackage{txfonts} (Mentioned in a comment of @Mico).

The way the box is ending is hardcoded in hyperref. IMHO it is better to use option colorlinks for hyperref, now the complete text of the link is colored. With for example option urlcolor=blue you can define the used color for url links ...

I would not use \\ to get the url string to a new line. To get a better-looking bibliography, I would use package ragged2e with command \RaggedRight.

With the complete MWE

\documentclass[12pt]{article}
%\special{papersize=8.5in,11in} % <========================= changed to:
\usepackage[total={8.5in,11in},centering,margin=1in]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}     % Support for french language
\usepackage[french]{babel}

%\usepackage{txfonts}  % 'txfonts' is deprecated; use newtxtext and newtxmath 
\usepackage{newtxtext,newtxmath}

\usepackage{ragged2e} % <====================== for command \RaggedRight
\usepackage{parskip} % <===================================== instead of 
%\setlength{\parindent}{0pt}
%\setlength{\parskip}{\baselineskip}

\usepackage{fancyhdr}
% Page configuration
\pagestyle{fancy}
\fancyhf{}
\rfoot{\thepage}
% Remove the header line
\renewcommand{\headrulewidth}{0pt}

\usepackage{listings}

\usepackage{graphicx} % <================================ pdftex deleted
\usepackage[usenames, dvipsnames]{xcolor} % <============ pdftex deleted

\usepackage[hyphens]{url}
\usepackage[%
  colorlinks, % <=======================================================
  urlcolor=blue,
]{hyperref} % <=============== 'pdftex' and 'breaklinks' options deleted



% Text Section
%=============

\begin{document}

{% start bibliography group
\RaggedRight
\begin{thebibliography}{9}
  \bibitem{svm}
    Analytics Vidhya: Understanding Support Vector Machine algorithm
    from examples (along with examples),
%   \\ % <==============================================================
    \url{https://www.analyticsvidhya.com/blog/2017/09/understaing-support-vector-machine-example-code/}
\end{thebibliography}
} % end bibliography group
\end{document}

results in the following pdf:

resulting pdf

  • 1
    +1. One more document aspect you could point out as being deprecated is the use of the txfonts package. Better to load the newtxtext and newtxmath packages. – Mico Feb 5 '18 at 5:25
  • 1
    @Mico Thanks, I added your comment to my question ... – Kurt Feb 5 '18 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.