Search code examples
latexbibtex

Alignment problem with ieeetran website citation


I am having difficulty getting properly aligned bibliography when citing a website (the url starts in the next line which causes huge horizontal gaps between words prior to the url).

Here is the screenshot from the "IEEEtran_bst_HOWTO.pdf":

enter image description here

Here is my output:

enter image description here

Note: The columnwidth is even wider in my code which should alleviate the problem.

My sample code is:

\documentclass[conference]{IEEEtran}

\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}

\ifCLASSINFOpdf
\else
\fi

\hyphenation{op-tical net-works semi-conduc-tor}

\begin{document}

\title{Bare Demo of IEEEtran.cls\\ for IEEE Conferences}

\author{\IEEEauthorblockN{Michael Shell}
\IEEEauthorblockA{School of Electrical and\\Computer Engineering\\
Georgia Institute of Technology\\
Atlanta, Georgia 30332--0250\\
Email: http://www.michaelshell.org/contact.html}
}

\maketitle

\IEEEpeerreviewmaketitle

\section{Introduction}

This demo file is intended to serve as a ``starter file''
for IEEE conference papers produced under \LaTeX\ using
IEEEtran.cls version 1.8b and later \cite{IEEEexample:bibtexFAQ}.

\bibliographystyle{IEEEtran}
\bibliography{ref}

\end{document}

And the bib file:

@electronic{IEEEexample:bibtexFAQ,
  author        = "David Hoadley and Michael Shell",
  title         = "{{\BibTeX}} Tips and {FAQ}",
  howpublished  = "{btxFAQ.pdf}",
  url           = "http://mirror.ctan.org/biblio/bibtex/contrib/doc/btxFAQ.pdf",
  month         = jan,
  year          = "2007"
}

Thank you in advance.


Solution

  • You can use the urlx package to add possible break points to the url:

    \documentclass[conference]{IEEEtran}
    
    \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
        T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
    
    \ifCLASSINFOpdf
    \else
    \fi
    
    \hyphenation{op-tical net-works semi-conduc-tor}
    
    \usepackage{xurl}
    
    \begin{document}
    
    \title{Bare Demo of IEEEtran.cls\\ for IEEE Conferences}
    
    \author{\IEEEauthorblockN{Michael Shell}
    \IEEEauthorblockA{School of Electrical and\\Computer Engineering\\
    Georgia Institute of Technology\\
    Atlanta, Georgia 30332--0250\\
    Email: http://www.michaelshell.org/contact.html}
    }
    
    \maketitle
    
    \IEEEpeerreviewmaketitle
    
    \section{Introduction}
    
    This demo file is intended to serve as a ``starter file''
    for IEEE conference papers produced under \LaTeX\ using
    IEEEtran.cls version 1.8b and later \cite{IEEEexample:bibtexFAQ}.
    
    \bibliographystyle{IEEEtran}
    \bibliography{ref}
    
    \end{document}