10

I got a new PC with Windows 10 Pro operating system several days ago and decided to install TeXstudio + MiKTeX.

And I faced a problem compiling LaTeX file. The problem is when I try to add \usepackage{hyperref} or code stuff similar to this line (more detailed in the code with the comment line % problem is here if I add this line) I get an error which says: Argument of � has an extra }. \end{document}.

My code:

\documentclass[10pt,a4paper]{report}
\usepackage{cmap}
\usepackage{setspace}
\onehalfspacing
\usepackage{multicol}
\usepackage{textcomp}
\usepackage{verbatim}
\usepackage{floatrow,calc}
\DeclareFloatSeparators{mysep}{\hspace{3cm}}
\thisfloatsetup{floatrowsep=mysep}
\usepackage{ucs}
\usepackage[pdftex]{graphicx}
\usepackage{epstopdf}
\usepackage{amssymb,amsmath}
\DeclareGraphicsExtensions{.pdf, .png, .jpg}
\usepackage[labelsep=period]{caption}
\usepackage[utf8x]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[russian, english]{babel}
\usepackage[left=3cm, right=1.5cm, top=1.5cm, bottom=2cm]{geometry}
\usepackage{indentfirst}
\usepackage{color}
\definecolor{Black}{rgb}{0,0,0}

\usepackage[unicode, colorlinks, linkcolor=Black]{hyperref} % problem is here if I add this line
\usepackage{xcolor}
\definecolor{linkcolor}{HTML}{000000}
\definecolor{urlcolor}{HTML}{000000}
\hypersetup{pdfstartview=FitH, linkcolor=linkcolor, urlcolor=urlcolor, colorlinks=True} % problem is here if I add this line
\fontfamily{ptm}
\parindent=1cm
\sloppy
\bibliographystyle{unsrt}
\usepackage{hyperref} % problem is here if I add this line

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lhead{\leftmark}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{1pt}

\usepackage{subfig}

\usepackage{epigraph} %%% to make inspirational quotes.

\usepackage{amsfonts}

\begin{document}

Random text
    
${\mathcal {E}}=-{{d\Phi_{B}} \over dt},$ where

${\mathcal {E}}$ — random letter.   

\end{document}

Error I get: Error

When I try this code in OverLeaf or on my notebook or without hyperref packages - everything's fine. But I need this package if, for example, I'll have to add references...

Did someone face similar problem? Maybe I need to install some other packages?

3
  • Please post your code block without line numbers, so we copy and paste it to test Jun 13, 2022 at 14:58
  • That being said, you shouldn't load hyperref in line 34, you already load it with different options in line 25 (which is a bit early, you should load it as one of last packages) Jun 13, 2022 at 15:00
  • I loaded it one of the last packages... Nothing has changed...
    – jus_iljas
    Jun 13, 2022 at 17:06

2 Answers 2

12

A quote from the hyperref maintainer:

But I would recommend to drop utf8x/ucs. Most improvements in the handling of utf8 which e.g. allow you to use them in \labels and filenames are undone by utf8x/ucs.

If the ucs package and utf8x inputenc option is removed, your code compiles.


  • Furthermore you should remove the pdftex from graphicx. It will automatically choose the best suited option to match your compilation chain.

  • You should also not load the same package multiple times, in particular not with different options

  • And load hyperref after the other packages (there are only very view exceptions)

  • No need to load color if you also load xcolor


\documentclass[10pt,a4paper]{report}
\usepackage{cmap}
\usepackage{setspace}
\onehalfspacing
\usepackage{multicol}
\usepackage{textcomp}
\usepackage{verbatim}
\usepackage{floatrow,calc}
\DeclareFloatSeparators{mysep}{\hspace{3cm}}
\thisfloatsetup{floatrowsep=mysep}
%\usepackage{ucs}
\usepackage[
%pdftex
]{graphicx}
\usepackage{epstopdf}
\usepackage{amssymb,amsmath}
\DeclareGraphicsExtensions{.pdf, .png, .jpg}
\usepackage[labelsep=period]{caption}
%\usepackage[utf8x]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[russian, english]{babel}
\usepackage[left=3cm, right=1.5cm, top=1.5cm, bottom=2cm]{geometry}
\usepackage{indentfirst}
\usepackage{xcolor}
\definecolor{Black}{rgb}{0,0,0}

\fontfamily{ptm}
\parindent=1cm
\sloppy
\bibliographystyle{unsrt}
%\usepackage{hyperref} % problem is here if I add this line

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lhead{\leftmark}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{1pt}

\usepackage{subfig}

\usepackage{epigraph} %%% to make inspirational quotes.

\usepackage{amsfonts}
%\usepackage{xcolor}
\usepackage[unicode, colorlinks, linkcolor=Black]{hyperref} % problem is here if I add this line

\definecolor{linkcolor}{HTML}{000000}
\definecolor{urlcolor}{HTML}{000000}
\hypersetup{pdfstartview=FitH, linkcolor=linkcolor, urlcolor=urlcolor, colorlinks=True} % problem is here if I add this line


\begin{document}

Random text
    
${\mathcal {E}}=-\frac{{d\Phi_{B}} }{ dt},$ where

${\mathcal {E}}$ — random letter.   

\end{document}
5
  • Thank you! This helped me a lot - I opened an old latex file to do some minor changes, and was baffled by the file not compiling, even though I know it compiled last time (3 years ago). Life saver :)
    – Katja Braz
    Jul 11, 2022 at 19:59
  • How to be about unicode characters without the inputenc package?
    – Cornul11
    Oct 12, 2022 at 13:19
  • @Cornul11 utf8 is the default input encoding in latex since sometime about 2018. Oct 12, 2022 at 13:21
  • @samcarter_is_at_topanswers.xyz, funny you say that since I cannot compile a project with pdflatex because it is complaining about some Unicode characters. I had to switch to XeLaTeX to fix this issue.
    – Cornul11
    Oct 13, 2022 at 14:04
  • @Cornul11 Can you make a minimal working example? Oct 13, 2022 at 14:07
-1

I encountered the same problem. I changed the Tex Live Version to 2021 and it was resolved. (Initially, it was 2022 in my setting. Setting can be found on Menu option at the top-left corner)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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