新环境无法读取某些命令的问题

新环境无法读取某些命令的问题

我已经创建了我的第一个新环境!我让它工作了,然后我一定做了什么,它就停止了。目的是创建一个“aside”环境,放置一个垂直空间,然后设置无衬线字体,然后设置另一个空间和普通字体。

当我运行下面的 MWE 时,它会放入第一个空格,然后转到无衬线字体,但不会放入第二个空格或切换回来。我盯着它看了 30 分钟,还是搞不懂。

\documentclass[openany, final]{memoir}


\usepackage{dialogue}


\OnehalfSpacing

\makeatletter
\renewcommand\partnumberlinehook[1]{%
  \settowidth{\@tempdima}{\bfseries #1 }%
}
\makeatother



\newenvironment{aside}
    {
     \vspace{0.2in}
     \begin{sffamily}
    }
    {
    \end{sffamily}
    \vspace{0.2in}
    }

\begin{document}

Then they take the bandages off and, as expected, my vision hasn't changed but
my eyes look much better.

\aside{The car crash and the eye surgery happened at around the same time, but
\ldots I don't remember which happened first and, at this point, there's no one
left alive who can tell me. I sort of \emph{think} that the eye surgery was
first. But I don't really know. And my thinking this is based on thinking, not
on the sort of sense of time that most people seem to have.

I think this is related to my NLD, I've heard of this sort of thing in some
other people withe NLD, but it's not the center of the diagnosis. It happens
with more minor life events too. I don't remember when things happened, or in
what order they happened.}

I've survived being hit by a cab, having eye surgery, and 7th grade, but 8th
grade is even worse.

\end{document}

当我在完整文档中运行它时,我收到一个不同的错误,“begin{\sffamily} ends by \end{document} 但是我无法为此找出一个好的 MWE。

答案1

环境使用的语法\begin{name}...\end{name}不是\name{...}

另外,注意行尾的空白(这里可以通过添加来避免%,并确保\par在添加垂直空间之前结束段落()。

dialog包似乎与回忆录类不兼容,因此我将其注释掉。

在此处输入图片描述

\documentclass[openany, final]{memoir}


%\usepackage{dialogue}


\OnehalfSpacing

\makeatletter
\renewcommand\partnumberlinehook[1]{%
  \settowidth{\@tempdima}{\bfseries #1 }%
}
\makeatother



\newenvironment{aside}
    {\par
     \vspace{0.2in}%
     \begin{sffamily}%
    }
    {%
    \end{sffamily}%
    \par
    \vspace{0.2in}%
    }

\begin{document}


Then they take the bandages off and, as expected, my vision hasn't changed but
my eyes look much better.

\begin{aside}
The car crash and the eye surgery happened at around the same time, but
\ldots I don't remember which happened first and, at this point, there's no one
left alive who can tell me. I sort of \emph{think} that the eye surgery was
first. But I don't really know. And my thinking this is based on thinking, not
on the sort of sense of time that most people seem to have.

I think this is related to my NLD, I've heard of this sort of thing in some
other people withe NLD, but it's not the center of the diagnosis. It happens
with more minor life events too. I don't remember when things happened, or in
what order they happened.
\end{aside}

I've survived being hit by a cab, having eye surgery, and 7th grade, but 8th
grade is even worse.

\end{document}

相关内容