3

Consider the following code:

\documentclass[
  a4paper,
  12pt
]{article}


\usepackage[
  hmargin=2.4cm,
  vmargin=3cm
]{geometry}
\usepackage{amssymb}
\usepackage{enumerate} % better to use enumitem
\usepackage{totcount}
\usepackage[
  colorlinks=true,
  urlcolor=black
]{hyperref}


\newcommand*\ops[1]{\textbf{\textsf{#1}}}
\newcommand*\options[3]{\color{#1}\ops{#2}\fontsize{#3}{#3}}
\newcommand*\film[4]{%
 \item \fontsize{12pt}{12pt} \selectfont \textsf{[#4] \enskip \href{#1}{#2}~(#3)}}
\setlength{\labelsep}{0em}
\renewcommand*\labelenumi{\options{blue}{\ops}{10pt} $\maltese$ \quad}

\regtotcounter{enumi}


\begin{document}

\begin{enumerate}
  \film{http://www.imdb.com/title/tt0134273/}{8MM}{1999}{6,4}
  \film{http://www.imdb.com/title/tt0050083/}{12 Angry Men}{1957}{8,9}
  \item\fontsize{12pt}{12pt}\selectfont \textsf{[2,1] \enskip \href{http://www.imdb.com/title/tt0057181/}{Incredibly Strange Creatures Who Stopped Living and Became Mixed-Up}}\\ \verb++\hspace{9.9mm} \textsf{{\href{http://www.imdb.com/title/tt0057181/}{Zombies, The}} (2006)}
\end{enumerate}

\noindent I have \total{enumi}~films.

\end{document}

How do I get automatically line breaking if a title is too long and left alignment of the title (as I have done manually for the last item) if it spans more than one line?

Follow-up question

Consider David's code:

\documentclass[
  a4paper,
  12pt
]{article}


\usepackage[
  hmargin=2.4cm,
  vmargin=3cm
]{geometry}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{totcount}
\usepackage[
  colorlinks=true,
  urlcolor=black
]{hyperref}


\newcommand*\film[4]{%
  \item[\refstepcounter{enumi}\textcolor{blue}{$\maltese$}\quad\textsf{[#4]}] \textsf{\href{#1}{#2}~(#3)}}


\regtotcounter{enumi}


\begin{document}

\begin{enumerate}[
  leftmargin=5em,
  labelindent=-5em
]
  \film{http://www.imdb.com/title/tt0134273/}{8MM}{1999}{6,4}
  \film{http://www.imdb.com/title/tt0050083/}{12 Angry Men}{1957}{8,9}
  \film{http://www.imdb.com/title/tt0057181/}{Incredibly Strange Creatures Who Stopped Living and Became Mixed-Up Zombies, The}{2006}{2,1}
\end{enumerate}

\noindent I have \total{enumi}~films.

\end{document}

What options do I have to give to enumerate in order to get the same alignment as in my initial code?

The problem is that with David's approach, there is too little space between the symbol and [x,y], and between [x,y] and the title. If I try to add some space, the symbol goes into the left margin.

Update 2

One last question: I would like an \if loop; something like

\if \total{enumi} = 1
  I have 1~film.
 \else
  I have \total{enumi}~films.
\fi

but it doesn't work. How do I do this?

1 Answers1

6

If you use \fontsize you need to follow it with \selectfont and its dangerous to use the same length in both arguments as usually it will lead to inconsistent line spacing.

enter image description here

\documentclass[
  a4paper,
  12pt
]{article}


\usepackage[
  hmargin=2.4cm,
  vmargin=3cm
]{geometry}
\usepackage{amssymb}
\usepackage{enumitem} % better to use enumitem
\usepackage{totcount}
\usepackage[
  colorlinks=true,
  urlcolor=black
]{hyperref}



\newcommand*\film[4]{%
 \item[\refstepcounter{enumi}\textcolor{blue}{$\maltese$} \textsf{[#4]}] \textsf{\href{#1}{#2}~(#3)}}


\regtotcounter{enumi}


\begin{document}

\begin{enumerate}[leftmargin=5em,labelindent=-5em]
  \film{http://www.imdb.com/title/tt0134273/}{8MM}{1999}{6,4}
  \film{http://www.imdb.com/title/tt0050083/}{12 Angry Men}{1957}{8,9}
\film{http://www.imdb.com/title/tt0057181/}{Incredibly Strange Creatures Who Stopped Living and Became Mixed-Up Zombies, The}{2006}{2,1}
\end{enumerate}

I have \total{enumi}~films.

\end{document}

or more spaced out

enter image description here

\newcommand*\film[4]{%
 \item[\refstepcounter{enumi}\textcolor{blue}{$\maltese$}\hspace{2em}\textsf{[#4]}] \textsf{\href{#1}{#2}~(#3)}}

..

\begin{enumerate}[leftmargin=15em,labelindent=-10em,align=left,labelwidth=10em]
David Carlisle
  • 757,742