How can I create a 'Nutrition Facts' label?

Here's my take.

I had to wait for a delayed train. ;-)

\documentclass[border=2]{standalone}
\usepackage{xparse}
\usepackage{booktabs}
\newlength{\NFwidth}
\setlength{\NFwidth}{2.5in}

\NewDocumentCommand{\NFelement}{mmm}{\large\textbf{#1} #2\hfill #3}
\NewDocumentCommand{\NFline}{O{l}m}{\makebox[\NFwidth][#1]{#2}}
\NewDocumentCommand{\NFentry}{sm}{%
  \makebox[.5\NFwidth][l]{\large
    \IfBooleanT{#1}{\makebox[0pt][r]{\textbullet\ }}%
    #2}\ignorespaces}
\NewDocumentCommand{\NFtext}{+m}
 {\parbox{\NFwidth}{\raggedright#1}}

\newcommand{\NFtitle}{\multicolumn{1}{c}{\Huge\bfseries Nutrition Facts}}

\newcommand{\NFRULE}{\midrule[6pt]}
\newcommand{\NFRule}{\midrule[3pt]}
\newcommand{\NFrule}{\midrule}

\begin{document}
\sffamily
\fbox{%
\begin{tabular}{@{}p{\NFwidth}@{}}
\NFtitle\\
\NFtext{Serving Size 2 tbsp.\ (33\,g)}\\
\NFtext{Servings Per Container 7}\\
\NFRULE
\NFline{Amount Per Serving}\\
\NFrule
\NFelement{Calories}{20}{Calories from Fat 10}\\
\NFRule
\NFline[r]{\% Daily Value*}\\
\NFrule
\NFelement{Total Fat}{1\,g}{2\%}\\
\NFrule
\NFelement{Sodium}{190\,mg}{8\%}\\
\NFrule
\NFelement{Total Carbohydrate}{2\,g}{1\%}\\
\NFrule
\NFelement{Protein}{1\,g}{}\\
\NFRule
\NFentry{Vitamin A 2\%}
\NFentry*{Vitamin C 15\%}\\
\NFentry{Iron 10\%}
\NFentry*{Vitamin B6 20\%}\\
\NFentry{Vitamin B12 4\%}\\
\NFrule
\NFtext{Not a significant source of saturated fat,
  trans fat, cholesterol, dietary fiber, sugars,
  and calcium.}\\
\NFrule
\NFtext{* Percent Daily Values are based on a
  2,000 calorie diet.}
\end{tabular}}
\end{document}

enter image description here


One possibility defining some auxiliary commands:

\documentclass{article}
\usepackage{graphicx}

\newcommand\myrule[1][1pt]{%
  \par\rule[1ex]{\linewidth}{#1}\par}

\newcommand\titlefont{\normalfont\Huge\bfseries}

\newcommand\Nline[3]{\textbf{#1}~#2\hfill#3\par}

\newcommand\Bullet[1]{\parbox{.5\linewidth}{\makebox[1em][l]{$\bullet$}#1}}

\newcommand\NutFact[3][8cm]{%
\par\noindent\resizebox{!}{#2}{\fbox{\begin{minipage}{#1}
\raggedright\sffamily
\vskip10pt
{\titlefont Nutrition Facts\par\medskip}
\large
#3
\end{minipage}}}%
}

\begin{document}

\NutFact{5cm}{%
Serving Size 2 tbsp. (33g) \par
Servings per Container 7\par
\myrule[9pt]
{\normalfont Amount per Serving\par}
\myrule
\Nline{Calories}{20}{Calories from Fat 10}
\myrule[6pt]
\hfill{\normalfont \% Daily Value\textsuperscript{*}\par}
\myrule
\Nline{Total Fat}{1g}{2\,\%}
\myrule
\Nline{Sodium}{190mg}{8\,\%}
\myrule
\Nline{Total Carbohydrate}{2g}{1\,\%}
\myrule
\Nline{Protein}{1g}{}
\myrule[11pt]
\Bullet{Vitamin A 10\,\%}%
\Bullet{Vitamin C 15\,\%}\par
\myrule
\Bullet{Iron 10\,\%}%
\Bullet{Vitamin B6 20\,\%}\par
\myrule
\Bullet{Vitamin B12 4\,\%}\par
\myrule
Not a significant source of satured fat, trans fat, cholesterol, dietary fiber, sugars, and calcium.
\myrule
\textsuperscript{*} Percent Daily Values are based on a 2,000 calorie diet.
}

\NutFact{4cm}{%
Serving Size 2 tbsp. (33g) \par
Servings per Container 7\par
\myrule[9pt]
{\normalfont Amount per Serving\par}
\myrule
\Nline{Calories}{20}{Calories from Fat 10}
\myrule[6pt]
\hfill{\normalfont \% Daily Value\textsuperscript{*}\par}
\myrule
\Nline{Total Fat}{1g}{2\,\%}
\myrule
\Nline{Sodium}{190mg}{8\,\%}
\myrule
\Nline{Total Carbohydrate}{2g}{1\,\%}
\myrule
\Nline{Protein}{1g}{}
\myrule[11pt]
\Bullet{Vitamin A 10\,\%}%
\Bullet{Vitamin C 15\,\%}\par
\myrule
\Bullet{Iron 10\,\%}%
\Bullet{Vitamin B6 20\,\%}\par
\myrule
\Bullet{Vitamin B12 4\,\%}\par
\myrule
Not a significant source of satured fat, trans fat, cholesterol, dietary fiber, sugars, and calcium.
\myrule
\textsuperscript{*} Percent Daily Values are based on a 2,000 calorie diet.
}

\end{document}

enter image description here

\NutFact has two mandatory arguments: the second one is the nutritional fact information, and the first one allows for some scaling; there's also an optional argument for the width of the inner minipage used.


With minipage you can do something.

Many other solution can do the job, e.g. with tabular

enter image description here

\documentclass{article}
\usepackage{siunitx}
\begin{document}


\begin{minipage}[h]{0.5\linewidth}
{\Large \bfseries Nutrition facts}

Serving Size tbsp. (\SI{33}{\gram})

Servings per container 7

\noindent\makebox[\linewidth]{\rule{\linewidth}{3pt}}

Amount per serving

\noindent\makebox[\linewidth]{\rule{\linewidth}{0.5pt}}

\textbf{Calories} \hfill Calories from Fat 10
\noindent\makebox[\linewidth]{\rule{\linewidth}{2pt}}

\flushright \% Daily Value \textsuperscript{*}

\noindent\makebox[\linewidth]{\rule{\linewidth}{0.5pt}}  
\flushleft
\textbf{Total Fat} \SI{1}{\gram} \hfill 2\%

\noindent\makebox[\linewidth]{\rule{\linewidth}{0.5pt}}

\textbf{Sodium} \SI{190}{\milli\gram}

\noindent\makebox[\linewidth]{\rule{\linewidth}{3pt}}
\begin{tabbing}
Vitamin A 2\% \quad \quad \= \textbullet\quad Vitamin C 15\%\\
Iron 10\% \> \textbullet \quad Vitamin B6 20\%
\end{tabbing}
\noindent\makebox[\linewidth]{\rule{\linewidth}{0.5pt}}
\footnotesize Not a significant source of saturated fat, trans
fat \ldots
\end{minipage}
\end{document} 

Tags:

Diagrams