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?

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]
  • I have a follow-up question; please see my updated question. – Svend Tveskæg Nov 8 '13 at 2:31
  • @SvendTveskæg 2nd example added – David Carlisle Nov 8 '13 at 9:16
  • Perfect, David! – Svend Tveskæg Nov 8 '13 at 10:28
  • I have one last, extra question, David; see updated question. – Svend Tveskæg Nov 8 '13 at 11:08
  • 1
    @SvendTveskæg you should ask new questions in a new question, but \if \total{enumi} tests if the first two non expandable tokens in the expansion of \total are the same. You meant to use ifnum but again that only works if \total{enumi} expands to a number which it certainly doesn't the first time. As you don't need back reference you don't need the totcount stuff and can just use \ifnum\value{enumi}=1 ... – David Carlisle Nov 8 '13 at 11:40

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.