我被错误消息“Extra \endgroup.\begin{document}”困住了。当我使用 menukeys 包时,会发生此错误。一个简短的工作示例是
\documentclass[12pt, oneside]{book}
\usepackage[a4paper, left=.7in, right=.7in, top=.7in, bottom=.6in, footskip=.25in]{geometry}
\usepackage{color, xcolor}
\usepackage[T1]{fontenc}
\usepackage{multirow}
\usepackage{enumitem}
\setlist{noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt,labelindent=1em,labelsep=10pt,leftmargin=*}
\usepackage{listings}
\newcommand{\rfunc}[1]{\lstinline{#1}} %% Short for 'R inline'
\lstset{language=R}
\lstset{ %
backgroundcolor=\color{white},
basicstyle=\small\ttfamily,
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
breaklines=true, % sets automatic line breaking
% captionpos=b, % sets the caption-position to bottom
commentstyle=\color{black}, % comment style
deletekeywords={...}, % if you want to delete keywords from the given language
% escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
% extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
frame=single, % adds a frame around the code
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
% keywordstyle=\color{black}, % keyword style
language=R, % the language of the code
% otherkeywords={*,...}, % if you want to add more keywords to the set
numbers=left, % where to put the line-numbers; possible values are (none, left, right)
% numbersep=5pt, % how far the line-numbers are from the code
% numberstyle=\tiny\color{mygray},% the style that is used for the line-numbers
rulecolor=\color{black},
% showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showstringspaces=false, % underline spaces within strings only
% showtabs=false, % show tabs within strings adding particular underscores
% stepnumber=2, % the step between two line-numbers. If it's 1, each line will be numbered
stringstyle=\color{black}, % string literal style
tabsize=2 % sets default tabsize to 2 spaces
}
\usepackage[os=win]{menukeys}
\renewmenumacro{\directory}{pathswithfolder}
\begin{document}
The use of \rfunc{panel} defines how different groups will be represented on the graph. When say \texttt{xyplot(y$\sim$x|z)} is entered on R console, R execute: \texttt{xyplot(y$\sim$x|z, panel=penal.xyplot)}, where \rfunc{panel.xyplot} is the default panel function. The \rfunc{lattice} package contains a number of predefined function that can call the other panel function, depending on the argument used.
\begin{lstlisting}
> xyplot(mpg ~ wt | factor(vs, levels = c(0, 1),
+ labels = c("vs = 0", "vs = 1")), data = mtcars,
+ type = c("p"), pch = 19,
+ panel = function( ... ){
+ panel.xyplot( ... )
+ panel.grid(... , h = -1, v = -1)
+ panel.loess( ... )} )
\end{lstlisting}
\end{document}
通过 MikeConsole 手动安装和更新软件包后的截图是