当我尝试在(from )cryptocode
中使用包时,我的代码生成:lapbox
adjustbox
ERROR: LaTeX Error: Something's wrong--perhaps a missing \item.
平均能量损失
\documentclass{article}
\usepackage{adjustbox}
\usepackage[colorlinks]{hyperref}
\usepackage [
n,
advantage,
operators,
sets,
adversary,
landau,
probability,
notions,
logic,
ff,
mm,
primitives,
events,
complexity,
asymptotics,
keys
]{cryptocode}
\createprocedureblock{game}{center,boxed}{}{}{}
\begin{document}
This is fine: \game[linenumbering]{A}{B}
This is fine:
\begin{minipage}[t]{\linewidth}
\lapbox[\textwidth]{0cm}{%
ABC
}%
\end{minipage}
This is not:
\begin{minipage}[t]{\linewidth}
\lapbox[\textwidth]{0cm}{%
\game[linenumbering]{A}{B}%
}%
\end{minipage}
\end{document}
编辑 想要的效果如下:
\documentclass{article}
\usepackage{adjustbox}
\usepackage[colorlinks]{hyperref}
\usepackage [
n,
advantage,
operators,
sets,
adversary,
landau,
probability,
notions,
logic,
ff,
mm,
primitives,
events,
complexity,
asymptotics,
keys
]{cryptocode}
\createprocedureblock{game}{center,boxed}{}{}{}
\usepackage{lipsum}
\begin{document}
\begin{itemize}
\item Goal: the left text should not be larger than this rule and go on the left instead:\\
\rule{.2\linewidth}{1mm}\\
\begin{minipage}[t]{.2\linewidth}
\lapbox[\textwidth]{0cm}{%
\mbox{I'd like to replace this with the game}
%%% Uncomment to see the breakage
%\game[linenumbering]{A}{B}%
}%
\end{minipage}\begin{minipage}[t]{.8\linewidth}
\lipsum[1]
\end{minipage}
\end{itemize}
\end{document}
答案1
好的,正如评论中所解释的(感谢 DavidCarlistle),似乎将我的环境包装成一个minipage
,或者更好的一个varwidth
(宽度有上限),其宽度会自动适应文本,从而产生预期的结果(不确定为什么,但似乎我需要给出一个大于框的长度)。
另请参阅我最近的问题自动缩放伪代码块以适合页面
\documentclass{article}
\usepackage{adjustbox}
\usepackage[colorlinks]{hyperref}
\usepackage [
n,
advantage,
operators,
sets,
adversary,
landau,
probability,
notions,
logic,
ff,
mm,
primitives,
events,
complexity,
asymptotics,
keys
]{cryptocode}
\createprocedureblock{game}{center,boxed}{}{}{}
\usepackage{lipsum}
\usepackage{varwidth}
\begin{document}
Hello
\begin{itemize}
\item Goal: the left text should not be larger than this rule and go on the left instead:\\
\rule{.2\linewidth}{1mm}\\
\begin{minipage}[t]{.2\linewidth}
\lapbox[\textwidth]{0cm}{%
\raisebox{-.5\height}{ % Align better baseline. Better solution?
\begin{varwidth}{10cm}%
\begin{pcimage}
\game[linenumbering]{A}{BBBBBBBBBB}
\end{pcimage}
\end{varwidth}
}
}%
\end{minipage}\begin{minipage}[t]{.8\linewidth}
\lipsum[1]
\end{minipage}
\end{itemize}
\end{document}