0

I am writing a thesis and I want to have two abstracts in different languages, English and Catalan. I started with a thesis template from my university (only in English) and then added the Babel package. I can successfully create two abstracts in different languages, but I'm not managing to change the name of the second Abstract to "Resum". Found online that Babel changes renewcommand so this is the solution for most people:

\addto{\captionscatalan}{\renewcommand{\abstractname}{Resum}}

This does not work for me, though, as the second one still appears as "Abstract". This is how I defined them:

\documentclass[a4paper, oneside]{discothesis}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,catalan]{babel} 
\begin{document}

%Abstract in English
\begin{abstract}
Abstract
\end{abstract}

%Abstract in Catalan
\begin{abstract}
\selectlanguage{catalan}
\addto{\captionscatalan}{\renewcommand{\abstractname}{Resum}}
Resum
\end{abstract}
\selectlanguage{english}

\end{document}

Also tried defining my own environment and got exactly the same result:

\documentclass[a4paper, oneside]{discothesis}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,catalan]{babel} 
\newenvironment{poliabstract}[1]
  {\renewcommand{\abstractname}{#1}\begin{abstract}}
  {\end{abstract}}
\begin{document}

\selectlanguage{english}
\begin{poliabstract}{Abstract} 
Abstract in english
\end{poliabstract}

\selectlanguage{catalan}
\begin{poliabstract}{Resum}
Resum en català
\end{poliabstract}

\selectlanguage{english}

\end{document}

The abstract is defined in this way in the cls file, haven't touched anything from the template file:

    \newenvironment{abstract}
    {\chapter*{Abstract}}
    {\vfill                 %kai
    \noindent               %kai
    \ifx \@keywords \@empty
        \relax
    \else
        {\bf Keywords:} \@keywords \\[6pt] %tobias
    \fi
% 
    \ifx \@categories \@empty
        \relax
    \else
        {\bf CR Categories:} \@categories   %tobias
    \fi

    \addcontentsline{toc}{chapter}{Abstract}
    }
3
  • Welcome. The definition of abstract in your template doesn't use \abstractname but defines the title simply as unnumbered chapter. You can't change it the way you try it. Furthermore, beside this uncommon way of setting the abstract title the abstract definition of your template uses commands which are not recommended to use anymore l like \bf. Thus, the whole template may be debatable. Do you have to use it?
    – lukeflo
    Aug 28, 2023 at 19:24
  • Well, I guess I don't HAVE to, but it was the most clear and easy to use template that I found with all the logos and formatting required, and I already made a lot of figures and tables using it...
    – alexb
    Aug 28, 2023 at 20:16
  • OK, then my most obvious answer would be, take the abstract environment with all its drawbacks (which may not disturb you at all) and redefine it to your needs. I could make very simple suggestion if you want...
    – lukeflo
    Aug 28, 2023 at 20:21

2 Answers 2

1

The name ‘Abstract’ is hardcoded in the (somewhat buggy) class. So you must redefine abstract, as suggested before. The following works for me, and it’s (imo) the canonical way the use two abstracts (I’m assuming Catalan is the main language):

\documentclass[a4paper, oneside]{discothesis}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,catalan]{babel} 

\makeatletter
\renewenvironment{abstract}
  {\chapter*{\abstractname}}
  {\vfill               %kai
  \noindent             %kai
  \ifx \@keywords \@empty
    \relax
  \else
    {\bf Keywords:} \@keywords \\[6pt] %tobias
  \fi
  \ifx \@categories \@empty
    \relax
  \else
    {\bf CR Categories:} \@categories   %tobias
  \fi
  \addcontentsline{toc}{chapter}{\abstractname}}
\makeatother

\begin{document}

\begin{otherlanguage}{english}
\begin{abstract}
Abstract
\end{abstract}
\end{otherlanguage}

\begin{abstract}
Resum
\end{abstract}

\end{document}

If the main language is English, reverse the order of languages (ie, catalan,english), and change the abstracts to:

\begin{abstract}
Abstract
\end{abstract}

\begin{otherlanguage}{catalan}
\begin{abstract}
Resum
\end{abstract}
\end{otherlanguage}

If you find further issues (for example, ‘Keywords’ is hardcoded, too), please extend your MWE.

3
  • +1 Maybe its best to merge both approaches. See my new edit.
    – lukeflo
    Aug 29, 2023 at 6:40
  • You might point out that \bf has been deprecated for about 30 years.
    – egreg
    Aug 30, 2023 at 8:35
  • @egreg: lukeflo already pointed it out. Aug 30, 2023 at 9:47
0

The definition of the abstract from your template is a little bit strange. But since you're more or less bound to the template, here's my simple and fast solution.

Just redefine the environment, using xparse and its check mechanisms for optional arguments, the following way in the praeambel:

\makeatletter
\RenewDocumentEnvironment{abstract}{o}{%
    \chapter*{\abstractname}%
    \IfValueT{#1}{\begin{otherlanguage}{#1}}%
}{%
    \vfill                 %kai
    \noindent               %kai
    \ifx \@keywords \@empty
        \relax
    \else
        {\bf Keywords:} \@keywords \\[6pt] %tobias
    \fi
% 
    \ifx \@categories \@empty
        \relax
    \else
        {\bf CR Categories:} \@categories   %tobias
    \fi
    \addcontentsline{toc}{chapter}{\abstractname}%
    \IfValueT{#1}{\end{otherlanguage}}%
}
\makeatother

Now you can use it the following way:

\begin{abstract}[<language-option>]
Text...
\end{abstract}

If the optional argument is left away, you use the main language of your document.

And you still can use the \addto{\captionscatalan}{\renewcommand{\abstractname}{Resum}} command, which is the recommended way with babel.

5
  • This seems to work in creating two working abstracts with different titles but latex outputs a lot of Illegal parameter number in definitions in the \end{abstract}, like \Hy@temp@A or \Hy@temp@B. Also, the name of the two abstracts appear empty in the table of contents and it triggers the Keywords and CR Categories.
    – alexb
    Aug 28, 2023 at 22:13
  • Updated the code. If it still doesnt work, this is surely due to the internal definition of commands like \@keywords which I can't explore.
    – lukeflo
    Aug 29, 2023 at 5:13
  • I've been trying for a while with abstractname and others but seems that I cannot get this code to work, but solution by @javierbezos worked.
    – alexb
    Aug 29, 2023 at 9:19
  • Then take the other one ;)
    – lukeflo
    Aug 29, 2023 at 9:24
  • I wrote the code on my smartphone, so I wasn't able to test it. Maybe not the best decision... At least, you got it working. I try to update my answer anyway if I got some time off.
    – lukeflo
    Aug 29, 2023 at 9:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .