1

I am currently working on a cook book and want to show some facts in the recipes with cookingsymbols.sty. I have problems displaying the symbols in a bullet list without the bullets. I already tried several different variants of writing it but keep getting errors. Can someone please direct me in the right direction?

\begin{infos}{}
\item[] \cookingtime{2 hours}  \\
\item[] \servings{2 persons}   \\
\item[] \oventime{180 degrees}
\end{infos}

I am using my own recipe.sty with the following code:

\newcommand{\cookingtime}[1]{\Interval & \hspace{-0.3cm} #1}
\newcommand{\servings}[1]{{\Large \Dish} & \hspace{-0.3cm} #1}
\newcommand{\oventime}[1]{{\Large \Oven} & \hspace{-0.3cm} #1}
\newcommand{\stovetime}[1]{{\Large \Gloves} & \hspace{-0.3cm} #1}

\newenvironment{infos}{
{\large {\bf Hard Facts}} \\
\par\smallskip
\begin{itemize}
\setlength{\itemsep}{-0.3cm}
}{
\end{itemize}
}

The errror I'm getting is the following:

Misplaced alignment tab character &. [\item[] \cookingtime{2 hours}]

Here is a minimal example

\documentclass{article}
\usepackage{cookingsymbols}

\newcommand{\cookingtime}[1]{\Interval & \hspace{-0.3cm} #1}
\newcommand{\servings}[1]{{\Large \Dish} & \hspace{-0.3cm} #1}
\newcommand{\oventime}[1]{{\Large \Oven} & \hspace{-0.3cm} #1}
\newcommand{\stovetime}[1]{{\Large \Gloves} & \hspace{-0.3cm} #1}

\newenvironment{infos}{
    {\large {\bf Hard Facts}} \\
    \par\smallskip
    \begin{itemize}
    \setlength{\itemsep}{-0.3cm}
}{
    \end{itemize}
}

\begin{document}

\begin{infos}{}
\item[] \cookingtime{2 hours}  \\
\item[] \servings{2 persons}   \\
\item[] \oventime{180 degrees}
\end{infos}

\end{document}
  • 2
    (1) welcome, (2) as always on this site, please post a full minimal example that others can copy and test. It is very hard to help when one does not know how the macros are defined. – daleif May 30 '18 at 11:25
  • @dasbabs Apparently the error comes from the \cookingtime command (which you didn't post) because the code you posted compiles fine if you replace them by, say, \textbf. – Phelype Oleinik May 30 '18 at 11:40
  • I've added the command as well. I'm sorry I'm pretty new to LaTeX – dasbabs May 30 '18 at 11:46
  • \Interval, \servings and \oventime are still missing in the MWE. – dexteritas May 30 '18 at 11:47
  • 1
    @PhelypeOleinik No worries :) Thank you for your help! I promise will do the MWE much better next time. – dasbabs May 30 '18 at 12:27
1

If you want to align the lines you could use a tabular instead of itemize. Because \Interval is not found I defined a dummy command for that.

If you want to adapt the spacing between the columns you can use @{\hskip 5pt}.

\documentclass{article}
\usepackage{cookingsymbols}

\newcommand{\Interval}{Int}

\newcommand{\cookingtime}[1]{\Interval & #1}
\newcommand{\servings}[1]{{\Large \Dish} & #1}
\newcommand{\oventime}[1]{{\Large \Oven} & #1}
\newcommand{\stovetime}[1]{{\Large \Gloves} & #1}

\newenvironment{infos}{
    {\large {\bf Hard Facts}} \\
    \par\smallskip
    \begin{tabular}{r@{\hskip 5pt}l}
}{
    \end{tabular}
}

\begin{document}

\begin{infos}{}
\cookingtime{2 hours}  \\
\servings{2 persons}   \\
\oventime{180 degrees}
\end{infos}

\end{document}

enter image description here

0

This is an alternative solution that uses the enumitem package to define infos as a new itemize-like list:

  • With \newlist, you just define a new environment (here: \begin{infos}...\end{infos}) copying all the settings from an existing list environment (here: itemize) for a predefined number of nesting levels (you just need one level here).
  • With \setlist, you change the properties of the list. See the enumitem manual for a full list of available settings. Here, I added the headline with the before key, and set some lengths (all customizable).
  • You can then use \item[...] inside your infos environment and put the respective symbol in the optional argument. For convenience, I defined some macros (as in your original example) as shorthands.
  • Note here: To have a better vertical alignment of the symbols and the text, I decided to use \raisebox to lower the symbols a bit. This is of course customizable.
\documentclass{article}
\usepackage{cookingsymbols}
\usepackage{enumitem}

\newlist{infos}{itemize}{1}
\setlist[infos]{%
    before={\noindent\textbf{\large Hard Facts}\\[-1.2\baselineskip]},
    itemsep=-2pt,
    itemindent=-5pt,
}

\newcommand{\servings}{\item[\raisebox{-2pt}{\Large\Dish}]}
\newcommand{\oventime}{\item[\raisebox{-2pt}{\Large\Oven}]}
\newcommand{\stovetime}{\item[\raisebox{-2pt}{\Large\Gloves}]}

\begin{document}

\begin{infos}
    \servings 2 persons
    \oventime 180 degrees
    \stovetime 2 hours
\end{infos}

\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.