latexbibtex

Apacite with natbib doesn't work, error: "File ended while scanning use of \UL@on. \bibliography{literatur}"


The publisher wants the APA-style for citations in my publication. Previously, I used the natbib package with the dinat style. When I change the package to apacite with the option natbibapa and the style to apacite, I get the following error:

File ended while scanning use of \UL@on. \bibliography{literatur}

Minimal working example

\documentclass[12pt]{scrartcl}

\usepackage{ucs}                
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[ngerman]{babel}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{enumitem}

\renewcommand{\labelenumi}{\theenumi)}

\usepackage{amsmath,amssymb,amstext,amsthm}

\usepackage{natbib} % This works fine.
\bibliographystyle{dinat}

%\usepackage[natbibapa]{apacite} % This gives the error mentioned above.
%\bibliographystyle{apacite}

\usepackage{setspace}

\usepackage{ulem}

\usepackage{geometry}
\geometry{a4paper, top=20mm, left=25mm, right=25mm, bottom=20mm,
    headsep=5mm, footskip=10mm}

\usepackage{booktabs}

\usepackage{ebgaramond}
\usepackage{AlegreyaSans}

\usepackage{filecontents}

\begin{filecontents}{literatur.bib}
    @Article{sadlerEtAl2007:SSI,
        author  = {Troy D. Sadler AND Sasha A. Barab AND Brianna Scott},
        journal = {Research in Science Education},
        title   = {What Do Students Gain by Engaging in Socioscientific Inquiry?},
        year    = {2007},
        pages   = {371--391},
        volume  = {37},
        doi     = {https://doi.org/10.1007/s11165-006-9030-9},
        groups  = {Socioscientific reasoning},
    }
\end{filecontents}

\usepackage{hyperref}
\hypersetup{hidelinks}

\begin{document}
         
         Citing some articles \citep{sadlerEtAl2007:SSI}
         
         \cite{sadlerEtAl2007:SSI}
         
         \citeyear{sadlerEtAl2007:SSI}

    \bibliography{literatur}
  
\end{document}

After each change of the packages I deleted all the aux, bbl, blg, log and out-files and compiled it again. I tried removing all non-necessary packages in the preamble. For one time it worked, but I couldn't figure out why. I thought the font-packages (ebgaramond and AlegreyaSans) were responsible. After reimplementing them, I got the same error message. So I removed them again but the error stayed. I tried requiring the apacite package, but that gave me even more errors. Using \PassOptionsToPackage{natbibapa}{apacite} also didn't change anything. Changing to apacite without natbibapa is not an option because of the huge number of citations in my paper. Using apalike is also not an option because it changes all capitals to lower cases which is wrong in the German language.


Solution

  • The ulem packages changes the definition of \emph, which conflicts with your bibliography. You can avoid the problem by using the normalem option:

    \documentclass[12pt]{scrartcl}
    
    %\usepackage{ucs}                
    %\usepackage[utf8x]{inputenc}
    \usepackage[T1]{fontenc}
    
    \usepackage[ngerman]{babel}
    
    \usepackage{graphicx}
    \usepackage{caption}
    \usepackage{subcaption}
    \usepackage{enumitem}
    
    \renewcommand{\labelenumi}{\theenumi)}
    
    \usepackage{amsmath,amssymb,amstext,amsthm}
    
    %\usepackage{natbib} % This works fine.
    %\bibliographystyle{dinat}
    
    \usepackage[natbibapa]{apacite} % This gives the error mentioned above.
    \bibliographystyle{apacite}
    
    \usepackage{setspace}
    
    \usepackage[normalem]{ulem}
    
    \usepackage{geometry}
    \geometry{a4paper, top=20mm, left=25mm, right=25mm, bottom=20mm,
        headsep=5mm, footskip=10mm}
    
    \usepackage{booktabs}
    
    \usepackage{ebgaramond}
    \usepackage{AlegreyaSans}
    
    \usepackage{filecontents}
    
    \begin{filecontents}{literatur.bib}
        @Article{sadlerEtAl2007:SSI,
            author  = {Troy D. Sadler AND Sasha A. Barab AND Brianna Scott},
            journal = {Research in Science Education},
            title   = {What Do Students Gain by Engaging in Socioscientific Inquiry?},
            year    = {2007},
            pages   = {371--391},
            volume  = {37},
            doi     = {https://doi.org/10.1007/s11165-006-9030-9},
            groups  = {Socioscientific reasoning},
        }
    \end{filecontents}
    
    \usepackage{hyperref}
    \hypersetup{hidelinks}
    
    \begin{document}
             
             Citing some articles \citep{sadlerEtAl2007:SSI}
             
             \cite{sadlerEtAl2007:SSI}
             
             \citeyear{sadlerEtAl2007:SSI}
    
        \bibliography{literatur}
      
    \end{document}