General ⇒ xcolor, savebox, bgroup problem
xcolor, savebox, bgroup problem
\documentclass{article}
\usepackage{xcolor}
\newsavebox{\mybox}
\savebox{\mybox}\bgroup hello world \egroup
\begin{document}
\usebox{\mybox}
\bgroup good bye world \egroup
\end{document}
gives me a missing "}" error with texlive 2010. If I do not use the package xcolor, I do not get an error. If I replace:
\savebox{\mybox}\bgroup hello world \egroup
with:
\savebox{\mybox}{hello world}
I do not get an error.
What am I doing wrong?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
xcolor, savebox, bgroup problem
Code: Select all
\documentclass{article}
\usepackage{xcolor}
\newsavebox{\mybox}
\savebox{\mybox}{\bgroup hello world \egroup}
\begin{document}
\usebox{\mybox}
\bgroup good bye world \egroup
\end{document}
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
xcolor, savebox, bgroup problem
Yes, I know. A slightly less minimal example that I think requires \bgroup and \egroup instead of curly braces is:localghost wrote:Usually the argument for the \savebox command needs to be grouped with curly braces.
Code: Select all
\documentclass{article}
\usepackage{xcolor}
\newsavebox{\mybox}
\newenvironment{myenv}{\savebox{\mybox}\bgroup}{\egroup\usebox{\mybox}}
\begin{document}
\begin{myenv}hello world\end{myenv}
\bgroup good bye world \egroup
\end{document}
! Missing } inserted.
<inserted text>
}
l.6 \begin{myenv}
hello world\end{myenv}
?
! Emergency stop.
when the xcolor package is used, but no error when the xcolor package is not used.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
xcolor, savebox, bgroup problem
Code: Select all
\newenvironment{myenv}{\savebox{\mybox}\bgroup}{\egroup\usebox{\mybox}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
xcolor, savebox, bgroup problem
Code: Select all
\savebox{\mybox}\bgroup hello world \egroup
localghost, thanks for the help so far.