Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have this code:

%Abstracts
\newcommand{\@spanishabstractname}{{\bfseries Resumen}}
\newsavebox\@sabstract
\newenvironment{spanishabstract}{%
    \lrbox\@sabstract\minipage{1\textwidth}\selectlanguage{spanish}\itshape}%
    {\endminipage\endlrbox\normalfont}

\newcommand{\@englishabstractname}{{\bfseries Abstract}}
\newsavebox\@eabstract
\newenvironment{englishabstract}{%
    \lrbox\@eabstract\minipage{1\textwidth}\selectlanguage{english}\itshape}%
    {\endminipage\endlrbox\normalfont}

%Making Title
\newcommand{\maketitle}{%
    \twocolumn[%
    {\centering \@spanishabstractname\par}\linespace
    \noindent\usebox{\@sabstract}\par\linespace
    \@skeyw\par\onecmskip
    {\centering \@englishabstractname\par}\linespace
    \noindent\usebox{\@eabstract}\par\linespace
    \@ekeyw
    ]
}

But when I use the command \maketitle in the document, not shows the boxes \@sabstract and \@eabstract, as follows.

Using maketitle

If I put the code definition of \maketitle in a \AtEndDocument:

\AtEndDocument{%
    \twocolumn[%
    {\centering \@spanishabstractname\par}\linespace
    \noindent\usebox{\@sabstract}\par\linespace
    \@skeyw\par\onecmskip
    {\centering \@englishabstractname\par}\linespace
    \noindent\usebox{\@eabstract}\par\linespace
    \@ekeyw
    ]
}

Everything works perfectly!

enter image description here

How I can fix this? Why wrong? Thanks!

share|improve this question
1  
Without a MWE it's not possible to help you. If I use some fragments of your code it will work. –  Marco Daniel May 19 '12 at 20:21
    
@egreg using \begin{lrbox} and \end{lrbox} it doesn't work. –  OSjerick May 19 '12 at 20:27
    
@MarcoDaniel the code correspond to a new LaTeX class, how I can give you a MWE? –  OSjerick May 19 '12 at 20:30

2 Answers 2

up vote 5 down vote accepted

The box is defined in a group (the environment), so it won't be available outside it. You need to set it globally:

\newcommand{\@spanishabstractname}{{\bfseries Resumen}}
\newsavebox\@sabstract
\newenvironment{spanishabstract}
  {\begin{lrbox}{8}
   \minipage{1\textwidth}\selectlanguage{spanish}\itshape}
  {\endminipage\end{lrbox}\global\setbox\@sabstract\box8 }

Similarly for the English abstract.

Using \lrbox and \endlrbox is not recommended. I would put the \bfseries instruction later (after \centering), not in the definition of \@spanishabstractname.

share|improve this answer
    
Thanks! @egreg but doesn't works, doing this occurs the same thing of my initial problem. –  OSjerick May 19 '12 at 20:37
    
@osjerick Then you're doing something wrong with your class. In my test (with what you provide) it works. –  egreg May 19 '12 at 20:41
    
Thanks! @egreg. –  OSjerick May 19 '12 at 20:47
    
@osjerick Did it work? –  egreg May 19 '12 at 20:53
    
No just I said Thanks! for your time. :) Any idea what might interfere with this in the rest of the code? –  OSjerick May 19 '12 at 20:56

I tried to create a MWE whereby the following commands I don't know:

  • \@ekeyw
  • \@skeyw
  • \linespace

Here the MWE

\documentclass{article}
\usepackage[spanish,english]{babel}
\usepackage{blindtext}
\makeatletter
%Abstracts
\newcommand{\@spanishabstractname}{{\bfseries Resumen}}
\newsavebox\@sabstract
\newenvironment{spanishabstract}{%
    \lrbox\@sabstract\minipage{1\textwidth}\selectlanguage{spanish}\itshape}%
    {\endminipage\endlrbox\normalfont}

\newcommand{\@englishabstractname}{{\bfseries Abstract}}
\newsavebox\@eabstract
\newenvironment{englishabstract}{%
    \lrbox\@eabstract\minipage{1\textwidth}\selectlanguage{english}\itshape}%
    {\endminipage\endlrbox\normalfont}

%Making Title
\renewcommand{\maketitle}{%
    \twocolumn[%
    {\centering \@spanishabstractname\par}
    \noindent\usebox{\@sabstract}\par
    \par
    {\centering \@englishabstractname\par}
    \noindent\usebox{\@eabstract}\par
    ]
}
\makeatother

\begin{document}
\begin{spanishabstract}
\blindtext
\end{spanishabstract}
\begin{englishabstract}
\blindtext
\end{englishabstract}

\maketitle
\end{document}
share|improve this answer
    
Ok! They are command that produces: "Palabras Claves:..." (\@skeyw) and "Key words:..." (\@ekeyw), and \linespace is \def\linespace{\vspace{17\p@}}. –  OSjerick May 19 '12 at 20:43
    
Thanks! @MarcoDaniel. –  OSjerick May 19 '12 at 20:48
    
@osjerick: Did you find the error? –  Marco Daniel May 19 '12 at 20:56
    
No just I said Thank! for your time. :) –  OSjerick May 19 '12 at 20:57
    
@osjerick: But the example works ;-) –  Marco Daniel May 19 '12 at 20:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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