问题描述
我正在尝试使用xcookybooky在LaTeX中编写食谱。当前的食谱(烤宽面条)含有太多成分,因此无法容纳在一页中。不幸的是,配料表并没有分成两页,文本只是从页面中移出了。
LaTeX代码本身就是在配方环境中制作的很长的配料表。 有人知道如何解决这个问题吗?
谢谢
编辑:我看到要添加的图片没有出现。取而代之的是,我将其中的一些代码复制到其中。尽管成分列表仍然不在页面中,但它可以为我进行编译。
\documentclass[
a4paper,11pt
]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{lmodern}
\usepackage[ngerman,english]{babel}
\usepackage{textcomp}
\usepackage{gensymb}
\usepackage{nicefrac}
\usepackage[
Nowarnings,]
{xcookybooky}
\DeclareRobustCommand{\textcelcius}{\ensuremath{^{\circ}\mathrm{C}}}
\setcounter{secnumdepth}{1}
\renewcommand*{\recipesection}[2][]
{
\subsection[#1]{#2}
}
\renewcommand{\subsectionmark}[1]
{
}
\usepackage{hyperref}
\begin{document}
\begin{recipe}
[%
preparationtime = {\unit[1]{h}},bakingtime={\unit[20-25]{min}},bakingtemperature={\protect\bakingtemperature{
fanoven=\unit[175]{\textcelcius}}},portion = {\portion{6}},]
{Spinach Lasagne}
\graph
{
%small=Recipes/MainCourses/BBQChicken/Small.jpg,big=Recipes/vegetarian/SpinachLasagne/Big.jpg
}
\ingredients
{
\textbf{Sauce}\\
2 & chopped onions\\
\unit[2]{tbsp} & Olive oil\\
3 & chopped cloves of garlic\\
\unit[2]{tsps} & dried thyme\\
4 & grated carrots\\
3 & grated celery leaves\\
1 & grated squash\\
1 & grated aubergine\\
\unit[250]{g} & mushrooms\\
\unit[1]{dL} & tomato paste\\
\unit[1]{can} & chopped tomatoes\\
To taste & salt and pepper\\
\\
\textbf{Spinach}\\
\unit[500]{g} & frozen spinach\\
\unit[1]{dL} & cream\\
1 & onion\\
1 & clove of garlic\\
\unit[2]{tbsp} & oil\\
To taste & salt \& pepper \& fresh basil\\
\\
\textbf{Mornay}\\
\unit[2]{tbsp} & butter\\
\unit[2]{tbsp} & flour\\
\unit[3]{dL} & milk\\
\unit[125]{g} & fresh mozzarella\\
To taste & salt \& pepper \& nutmeg\\
\\
\unit[250]{g} & Lasagne plates\\
Enough & mozzarella
}
\end{recipe}
\end{document}
解决方法
xcookybooky
手册中记录了由于技术原因不可能在配料表中出现换行符。
不过,您可以像这样临时重新实现recipe
和ingredients
宏:
\documentclass[
a4paper,11pt
]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{lmodern}
\usepackage[ngerman,english]{babel}
\usepackage{textcomp}
\usepackage{gensymb}
\usepackage{paracol}
\usepackage{supertabular}
\usepackage{lipsum}
\usepackage{nicefrac}
\usepackage[
nowarnings,]
{xcookybooky}
\DeclareRobustCommand{\textcelcius}{\ensuremath{^{\circ}\mathrm{C}}}
\setcounter{secnumdepth}{1}
\renewcommand*{\recipesection}[2][]
{
\subsection[#1]{#2}
}
\renewcommand{\subsectionmark}[1]
{
}
\usepackage{hyperref}
\begin{document}
\begingroup
\makeatletter
\renewenvironment{recipe}[2][]
{% initialisation
\setkeys{recipe}{preparationtime,bakingtime,bakingtemperature,portion,calory,source}
\setkeys{picture}{small,big,smallpicturewidth=\xcb@smallpicturewidth,bigpicturewidth=\xcb@bigpicturewidth} % load the default values
\def\xcb@hook@pregraph{}
\def\xcb@hook@pretitle{}
\def\xcb@introduction{}
\def\xcb@hook@prepreparation{}
\preparation{}
\def\xcb@hook@postpreparation{}
\def\xcb@hook@preingredients{}
\ingredients{}
\def\xcb@hook@postingredients{}
\def\xcb@suggestion{}
\def\xcb@hint{}
\def\xcb@recipename{#2}
\setkeys{recipe}{#1} % reading the optional parameters
\setcounter{xcb@newpagefoot}{1}
\setcounter{xcb@newpagehead}{\value{page}}
}
{% this part is executed at \end{recipe}
%% FIRST BLOCK
\xcb@hook@pregraph
\if@twoside
\ifodd\arabic{page}
\begin{minipage}[T]{\xcb@picture@bigwidth}
\xcb@picture@big
\end{minipage}
\hfill
\begin{minipage}[T]{\xcb@picture@smallwidth}
\xcb@picture@small
\end{minipage}
\else
\begin{minipage}[T]{\xcb@picture@smallwidth}
\xcb@picture@small
\end{minipage}
\hfill
\begin{minipage}[T]{\xcb@picture@bigwidth}
\xcb@picture@big
\end{minipage}
\fi
\else
\begin{minipage}[T]{\xcb@picture@bigwidth}
\xcb@picture@big
\end{minipage}
\hfill
\begin{minipage}[T]{\xcb@picture@smallwidth}
\xcb@picture@small
\end{minipage}
\fi
%% SECOND BLOCK
\xcb@hook@pretitle
\recipesection[\normalsize\xcb@recipename]%
{\hspace{-1em}\textcolor{\xcb@color@recipename}{\xcb@font@recipename\xcb@recipename}}
\xcb@cmd@recipeoverview
\xcb@introduction
%% THIRD BLOCK
\columnratio{0.66}
\begin{paracol}{2}
\xcb@hook@prepreparation
\xcb@preparation
\xcb@hook@postpreparation
\xcb@suggestion
\vfill
\xcb@cmd@wrapfill
\xcb@hint
\setcounter{xcb@newpagefoot}{0}
\switchcolumn
\xcb@hook@preingredients
\xcb@ingredients
\xcb@hook@postingredients
\end{paracol}
}
\renewcommand*{\ingredients}[2][\empty]
{% The optional argument contains the number of lines
\def\xcb@ingredientslines{#1}
\def\xcb@ingredients
{%
\xcb@name@inghead
\\[1em]
{\xcb@fontsize@ing\color{\xcb@color@ing}
\begin{supertabular}{r>{\raggedright\arraybackslash}p{3cm}}
#2
\end{supertabular}}
}
}
\makeatother
\begin{recipe}
[%
preparationtime = {\unit[1]{h}},bakingtime={\unit[20-25]{min}},bakingtemperature={\protect\bakingtemperature{
fanoven=\unit[175]{\textcelcius}}},portion = {\portion{6}},]
{Spinach Lasagne}
\graph
{
%small=Recipes/MainCourses/BBQChicken/Small.jpg,big=example-image
}
\ingredients
{
\textbf{Sauce}\\
2 & chopped onions\\
\unit[2]{tbsp} & Olive oil\\
3 & chopped cloves of garlic\\
\unit[2]{tsps} & dried thyme\\
4 & grated carrots\\
3 & grated celery leaves\\
1 & grated squash\\
1 & grated aubergine\\
\unit[250]{g} & mushrooms\\
\unit[1]{dL} & tomato paste\\
\unit[1]{can} & chopped tomatoes\\
To taste & salt and pepper\\
\\
\textbf{Spinach}\\
\unit[500]{g} & frozen spinach\\
\unit[1]{dL} & cream\\
1 & onion\\
1 & clove of garlic\\
\unit[2]{tbsp} & oil\\
To taste & salt \& pepper \& fresh basil\\
\\
\textbf{Mornay}\\
\unit[2]{tbsp} & butter\\
\unit[2]{tbsp} & flour\\
\unit[3]{dL} & milk\\
\unit[125]{g} & fresh mozzarella\\
To taste & salt \& pepper \& nutmeg\\
\\
\unit[250]{g} & Lasagne plates\\
Enough & mozzarella\\
}
\preparation{
\step \lipsum[2]
\step \lipsum[2]
\step \lipsum[2]
\step \lipsum[2]
\step \lipsum[2]
\step \lipsum[2]
}
\end{recipe}
\endgroup
\end{document}
注意事项:
-
成分列的宽度是硬编码的。将
p{3cm}
更改为适合您的值 -
“准备”列将不会包裹所有成分。