2

I am using the itemize environment to generate a list of web applications and thheir URLs as follows:

\documentclass{11pt,letter]{article}
\begin{document}
\begin{itemize}
\item[site name:]{\url{https://this-is-a-very-long-url.example.com}}
\item[site2 name]{\url{https://this-is-an-even-longer-url-so-that-hopefully-it-will-go-beyond-the-line.example.com}}
\end{itemize}
\end{document}

When I generate the pdf document, the site urls get truncated because they are too long to fit next to the site name on the same line.

Is there a way to have the text display like this?

site name:
  site url
site2 name:
  site2 url

Obviously I could use a verbatim or fancyvbr environment to accomplish this, but I would like the bullets from the list environment as well.

any help greatly appreciated.

6
  • Use a description environment and the package enumitem. But what exactly do you mean with the "bullets" (you override them, don't you)?
    – TeXnician
    Oct 19, 2017 at 18:08
  • 4
    Please make your code snippet compilable!
    – Mensch
    Oct 19, 2017 at 18:10
  • @texnician, sorry, I am blind and sometimes the way things are printed doesn't translate into what I can tell. So the things in the square brackets override the bullets I guess :)
    – dnraikes
    Oct 19, 2017 at 18:16
  • @texnician, can you provide an example of your solution?
    – dnraikes
    Oct 19, 2017 at 18:19
  • Try something like \usepackage{enumitem} in the preamble and replacing the itemize environment with \begin{description}[style=nextline] (and the proper ending).
    – TeXnician
    Oct 19, 2017 at 18:25

2 Answers 2

2

You can use \usepackage[hyphens]{url}:

enter image description here

Notes:

  • The optional paramater to \item overrides the bullet.
  • There is no mandator paramater to \item. Thusn, no need to have an additional {} around the \url.

Code:

\documentclass[11pt,letter]{article}
\usepackage[hyphens]{url}

\begin{document}
\begin{itemize}
\item[site name:] \url{https://this-is-a-very-long-url.example.com}
\item[site2 name] \url{https://this-is-an-even-longer-url-so-that-hopefully-it-will-go-beyond-the-line.example.com}
\end{itemize}
\end{document}
2

You can use the description style nextline from enumitem and load url with the [hyphens] option:

\documentclass[11pt, letter]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\usepackage[hyphens]{url}

\begin{document}

\begin{description}[style=nextline, font=\normalfont]
\item[Site name:] \url{https://this-is-a-very-long-url.example.com}
\item[Site2 name]\url{https://this-is-an-even-longer-url-so-that-hopefully-it-will-go-beyond-the-line.example.com}
\end{description}

\end{document} 

enter image description here

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.