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?
CodePudding user response:
A quote from the hyperref documentation:
Note: utf8 is now the default in LATEX and ucs is no longer recommended.
If ucs
and utf8x
is removed, your code compiles.
Furthermore you should remove the
pdftex
fromgraphicx
. 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 loadxcolor
\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}