带有时间轴的烹饪食谱

带有时间轴的烹饪食谱

每当有家人或朋友来访时,我都喜欢做大餐,但在准备不同菜肴时,我的时间管理往往很吃力。这就是为什么我想创建一个模板,把所有不同的步骤及其各自的持续时间都放进去,然后转换成一个时间表。有没有类似的东西——也许是不同的模板或套餐——我可以用它作为起点?

提前谢谢了!

答案1

在我研究烹饪排版的这些年里,我一直避免尝试时间轴食谱。即使是最简单的食谱,一旦你开始分解它,也会出奇地复杂:将这种复杂性与时间轴机制结合起来似乎太过分了。因此,我怀着很大的羞怯提交了这篇文章。不过,你的问题引起了我的兴趣。你没有具体说明你想看到什么,所以除了时间轴本身之外,我几乎没有什么限制。

这种格式和类似格式的食谱需要什么(例如,表格配方符号可以在以下网址查看https://www.cookingforengineers.com/recipe/58/Peanut-Butter-Cookies-- 朝向底部),是简洁,通常不是烹饪写作的显著特征。无论如何,这种格式和类似格式的食谱更可能是一个总结,或者一个备忘录而不是完整、详细的菜谱。

颜色:随机选择,不只是视觉效果,还可以更清晰地区分步骤及其在时间线上的位置(特别是指示起点的连接器和显示终点的禁止规则)。如果需要,可以关闭。

Varwidth:这些步骤包含在varwidth环境中。这些环境的宽度仅与它们需要的宽度相同,最大可能是宏\stepwd的第四个(可选)参数\step——默认值目前为 1 英寸,但可以在前言中更改。要使用 minipages,请将选项添加dominipgrecipe环境中

代码很冗长,但注释相当充分,并且后面还有一些附加材料\end{document}

我已尝试使信息输入尽可能简单明了。 时间线示例

\documentclass{article}

\usepackage[%showframe,
    papersize={11in,8.5in},margin=0.5in]{geometry}
\usepackage[rgb]{xcolor}% <<-necessary for use of hsb color space>>
\usepackage{fontspec,xparse,tikz,varwidth,keyval}

\usetikzlibrary{calc,positioning,backgrounds,chains,arrows.meta}

\newcounter{stepnum}
\newif\ifbotrec
\newif\ifdominipg
\newif\ifnocolor
\newsavebox{\recbox}
\newtoks\tlntox
\newlength{\tlnwidth}
\newlength{\stepwd}
\newlength{\mvstep}
\newlength{\stepoffset}
\newlength{\nodedist}

\colorlet{recipecolor}{red}
\setlength{\tlnwidth}{\textwidth}
\setlength{\stepwd}{1in}
\setlength{\mvstep}{2pt}
\setlength{\stepoffset}{18pt}
\setlength{\nodedist}{6pt}
\def\nocolorcolor{}

%% |=====8><-----| %%

\makeatletter
%% \step options:
\define@key{timelst}{Bot}[true]{\csname botrec#1\endcsname}%% below timeline
\define@key{timelst}{Top}[false]{\csname botrec#1\endcsname}%% above timeline
%% recipe environment options:
\define@key{timel}{dominipg}[true]{\csname dominipg#1\endcsname}%% if true, use minipages, not varwidth
\define@key{timel}{nocolor}[true]{\csname nocolor#1\endcsname}%if true, stop random colors
\define@key{timel}{nocolorcolor}{\def\nocolorcolor{#1}}% if nocolor=true use this color
\define@key{timel}{recipecolor}{\colorlet{recipecolor}{#1}}%% main recipe color
\define@key{timel}{tlnwidth}{\setlength{\tlnwidth}{#1}}%% width of timeline
\define@key{timel}{mvstep}{\setlength{\mvstep}{#1}}%% small vertical offset to avoid line colisions
\define@key{timel}{stepoffset}{\setlength{\stepoffset}{#1}}%%dist. timeline to first connector bend
\define@key{timel}{nodedist}{\setlength{\nodedist}{#1}}%% horizontal distance between steps
\makeatother

%% |=====8><-----| %%

\makeatletter  %% {\foo}{A}{B}
\def\instring#1#2{TT\fi\begingroup\edef\x{\endgroup\noexpand\in@{#1}{#2}}\x\ifin@}
\makeatother
\def\whyph#1-#2|{\def\FROM{#1}\def\TO{#2}}
\def\wohyph#1|{\def\FROM{#1}\def\TO{}}

\NewDocumentCommand{\mkrule}{O{recipecolor}}{%
    \nointerlineskip
    \vskip0pt
    \textcolor{#1}{\hrulefill}%
    \par
    \nointerlineskip
    \vskip0pt
}

%% format the ingredients -- bold; the hanging indentation happens in the varwidth environments
\NewDocumentCommand{\ingreds}{ >{\SplitList{;}}m }{\ProcessList{#1}{\fooaux}}
\NewDocumentCommand{\fooaux}{ m } {\expandafter\fooauxa#1|}% #1*=\hrulefill?; #2=ingredients
\NewDocumentCommand{\fooauxa}{s O{0pt} u{|}}{%
    \bfseries\strut#3\strut\par
    \IfBooleanT{#1}{%
        \mkrule
    }%
}

%% #1*=?; [#2=keyval]l #3=title; #4=start #5=end
\NewDocumentEnvironment{recipe}{s O{} m m m}{%
    \setkeys{timel}{#2}%
    \colorlet{cmpreccol}{rgb:-recipecolor, 5;black, 3}% complement, darkened
    \pgfmathsetmacro{\tlndur}{#5 - #4}%
    \pgfmathsetmacro{\startrec}{#4}%
    \pgfmathsetmacro{\finishrec}{#5}%
    \tlntox={}%
    \setcounter{stepnum}{0}%
}{%
    \centering
    \begin{tikzpicture}[draw,%
        start chain=toprec going {right=of \tikzchainprevious.south east},
        start chain=botrec going {right=of \tikzchainprevious.north east},
        outer sep=0pt,
        node distance=\nodedist]
        \draw[timeline](0,0)coordinate(ST) -- (\tlnwidth,0)coordinate(ET); %timeline
        \begin{scope}[on background layer]
            \foreach \n [count=\m from 0] in {#4,...,#5}
                {\node[font=\Huge\bfseries,text=lightgray,name=H\n]
                    at ($(ST)!\m/\tlndur!(ET)$) {\n};}%% numbers on timeline
        \end{scope}
        \the\tlntox
        \node[above right=0pt and 0pt of current bounding box.north west -| ST,
            name=T,font=\Large\bfseries\itshape,text=recipecolor] {#3};%% title node
    \end{tikzpicture}%
    \par
    \bigskip
}

\tikzset{%
    stepnode/.style n args = {3}{thick,fill=stephue!10,draw=stephue,name=#1,on chain=#2,anchor=#3},
    connector/.style={stephue,very thick,-{Stealth[]},rounded corners=3pt},
    timeline/.style={recipecolor,very thick,{Latex[]}-{Latex[]}},
    endshow/.style={ultra thick,stephue!50,-{Bar[]}},
    stnum/.style={font=\sffamily\scriptsize,draw=stephue,very thin,
        fill=stephue!10,circle,inner sep=1pt}
}

\NewDocumentCommand{\mkstep}{+m o m}{%utility macro: #1=method text; [#2=ingredients]; #3=step width
    \ifdominipg \begin{minipage}{#3} \else \begin{varwidth}{#3}\fi% or minipage if you like
        \IfNoValueF{#2}{%
            \begingroup
                \leftskip1.25em
                \parindent-1.25em
                \rightskip0pt plus 3em
                \ingreds{#2}%
                \mkrule[cmpreccol]
            \endgroup
            \smallskip
        }
        \rightskip0pt plus 3em
        \strut#1\strut\par
    \ifdominipg \end{minipage} \else\end{varwidth}\fi% or minipage
}

%% #1 keyval,#2 method, [#3 ingredients] (;-separated list), #4 start<-end>; #5=[step width]
\NewDocumentCommand{\step}{O{} +m o m O{\stepwd} D<>{0pt}}{%
    \setkeys{timelst}{#1}%
    \if\instring{-}{#4}\expandafter\whyph#4| \else \wohyph#4|\fi
    \stepcounter{stepnum}%
        \edef\foo{\tlntox={\the\tlntox
            \ifnocolor
                \ifx\empty\nocolorcolor
                    \noexpand\colorlet{stephue}{recipecolor}%
                \else
                    \noexpand\colorlet{stephue}{\nocolorcolor}
                \fi
            \else
                \noexpand\pgfmathsetmacro{\noexpand\huenum}{rnd}% 
                \noexpand\definecolor{stephue}{hsb}{\noexpand\huenum,0.8,0.8}%
            \fi
            \ifbotrec % below the timeline
                \noexpand\begin{scope}[yshift=-\stepoffset,xshift=#6]
                    \noexpand\node[stepnode={BOT\thestepnum}{botrec}{north west},yshift=-\mvstep]
                        {%content
                            \noexpand\mkstep{#2}[#3]{#5}% Does the work of formatting the step
                        };
                \noexpand\end{scope}
                \noexpand\draw[connector] (BOT\thestepnum.north) --
                    ++(0,8pt) -|
                    ($(ST)!{(\FROM-\startrec)/\tlndur}!(ET)$); %% draw connector
                \ifx\empty\TO \else %% draw completion arrow if \TO exists
                    \noexpand\begin{scope}[on background layer]
                        \noexpand\draw[endshow](BOT\thestepnum) --
                            (BOT\thestepnum -| H\TO); 
                    \noexpand\end{scope}
                \fi
                \noexpand\node[stnum]
                    at (BOT\thestepnum.north west){\thestepnum};
            \else % above the timeline
                \noexpand\begin{scope}[yshift=\stepoffset,xshift=#6]
                    \noexpand\node[stepnode={TOP\thestepnum}{toprec}{south west},yshift=\mvstep]
                        {%content
                            \noexpand\mkstep{#2}[#3]{#5}% Does the work of formatting the step      
                        };
                \noexpand\end{scope}
                \noexpand\draw[connector] (TOP\thestepnum.south) --
                    ++(0,-8pt) -|
                    ($(ST)!{(\FROM-\startrec)/\tlndur}!(ET)$); %% draw connector
                \ifx\empty\TO \else %% draw completion arrow if \TO exists
                    \noexpand\begin{scope}[on background layer]
                        \noexpand\draw[endshow](TOP\thestepnum) --
                            (TOP\thestepnum -| H\TO); 
                    \noexpand\end{scope}
                \fi
                \noexpand\node[stnum]at (TOP\thestepnum.north west){\thestepnum};               
            \fi
        }%
    }\foo
    \botrecfalse
}

%% |=====8><-----| %%

\parindent0pt

\begin{document}

\small

\thispagestyle{empty}

\begin{recipe}[dominipg,tlnwidth=7in]{Testing Timeline}{7}{16}
\step{Here is a step with absolutely no ingredients whatsoever that should finish up around noon or so.}{8-12}[2in]
\step{Mix it up and serve it forth at one o'clock.}[*1 cup extra virgin olive oil;2 tsp. henbane;3 cups vinegar]{10-13}
\step[Bot]{bla}[a;*b;c]{11}[1.25in]
\step[Bot]{more bla\par bla bla that just  might be excessive}{11.75-13}[1.5in]
\step[Bot]{yada yada yada}{14-15}
\end{recipe}

\begin{recipe}[recipecolor=orange,tlnwidth=9.5in,mvstep=3pt,stepoffset=18pt,nodedist=18pt]{Testing Timeline II}{7}{16}
\step{blablabla which might go on and on for an useemly time\dots}{8-12}[1in]
\step{more bla bla bla}[*1 cup extra virgin olive oil;2;3]{10}
\step[Bot]{blablabla}[a;*b;c]{11}[3.5in]<2in>
\step[Bot]{more bla\endgraf bla bla which could go on and on seemingly forever, and on and on and on ad infinitum}{11.25-13}[1in]
\step[Top]{$A=\pi r^2$ \par more bla\par bla bla}[*1 cup extra virgin olive oil;2;3]{14}
\step[Bot]{Open the Champagne!}{16}
\end{recipe}

\end{document}



Chains: two `TikZ` `chain`s are used to place the steps; the distance between the chain elements is controlled by an option to `recipe`, `nodedist`.

The `recipe` environment takes 4 arguments:
    #1 (optional) keyval options:
            dominipg: use minipage instead of varwidth
            nocolor: turns off random coloring of steps, uses recipecolor
            nocolorcolor: if specified and nocolor is in effect, specifies the color
                to use instead of recipecolor
            recipecolor:  main recipe color
            tlnwidth:  width of timeline, if not set, defaults to \textwidth
            mvstep:  small vertical offset to avoid connector line colisions
            stepoffset: distance from timeline to first connector bend
            nodedist:  horizontal distance between steps, sets for *all* steps
    #2 the title of the timeline
    #3 the start of the time line (in 24-hour decimal format)
    #4 the end of the time line (in 24-hour decimal format)

The `\step` macro takes 6 arguments:
    #1 keyval, optional: `Top` (default) for above the timeline, `Bot` for below.
    #2 required, method: text of the method, can have implicit or explicit `\par`s
    #3 optional, ingredients in a ;-separated list
    #4 required, start<-end>: A single digit will show only the start time; two digits with a hyphen (e.g., 3-5) will show `3` as the start, with a barred rule showing the duration at `5`.
    #5 [step width] optional; if not given will use default.
    #6 The sixth argument (optional) to `\step` (`<...>`) (+ right, - left), works, but only once for the two layers of steps - above and below the timeline. Given as a dimension.

Step numbers are shown at the upper left of the step boxes, and reflect the order in which the steps were input.

The `Top` and `Bot` options to the `\step` macro: `Top` is the default, and is optional at the start of input.

相关内容