4

I'm using XeLaTeX because of language problem.

The following code has no problem:

\documentclass{article}

%\usepackage{mdframed}

\newenvironment{mynote}{\footnote\bgroup}{\egroup}
\begin{document}
Hello\begin{mynote} world\end{mynote}.
\end{document}

However, the following code gives an error:

\documentclass{article}

\usepackage{mdframed}

\newenvironment{mynote}{\footnote\bgroup}{\egroup}
\begin{document}
Hello\begin{mynote} world\end{mynote}.
\end{document}

What is the reason for the error and how can I resolve it?

  • \footnote, in LaTeX, can't be followed by \bgroup in order to build its argument. If it appears to work is just by chance and it will be typeset incorrectly anyway. – egreg Jun 3 '14 at 20:43
  • 1
    The reason why this fails with mdframed is because the package adds code to \begin and \end. But trust me: your mynote environment doesn't work correctly. – egreg Jun 3 '14 at 20:48
5

With environ you can define an environment which collects the body for later use.

\documentclass{article}
\usepackage{mdframed,environ}
\newsavebox\NBox
\NewEnviron{mynote}{\footnote{\BODY}}

\begin{document}
Hello\begin{mynote} world\end{mynote}.
\end{document}
  • Thank you. Your solution resolved the problem. However, I still wonder why the second code have not worked... – seoneo Jun 3 '14 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.