0

I have a document at hand that was written by using an old template and now I want to copy it to a new one. However, when I do this and execute the code I am facing the error

Missing $ inserted.

for all inline math modes. That's because in my initial template I used the symbol \( \) to write all the inline math equations and somehow my new template does not accept this notation but forces me to use $ instead. So, my question is: What should I do to define the equality $...$ = \(...\) or how can I interchange these two?

sahin
  • 277
  • By help -- "find/replace" function -- of used LaTeX editor? – Zarko Oct 18 '15 at 18:47
  • try \usepackage{amsmath} – touhami Oct 18 '15 at 18:50
  • 2
    For me \( and \) are working, no matter what I try. Please provide MWE, so we can figure out, where the problem is. – Wamseln Oct 18 '15 at 18:55
  • @Zarko it will be painful to use it through all the document, what I am looking is actually a preamble code that interchanges these two symbols, if possible. – sahin Oct 18 '15 at 18:57
  • @touhami I am using this package already. – sahin Oct 18 '15 at 18:58
  • You could try \renewcommand{\(}{$} and \renewcommand{\)}{$}... But without MWE it's just guessing. – Wamseln Oct 18 '15 at 19:00
  • @sahin, well, use editor to do work for you, this should not be so painful. Just two its passes through your document without of any your intervention? Anyway, you have many other suggestion, what to do. Myself I will use editor for this job. – Zarko Oct 18 '15 at 19:06
  • try \makeatletter\DeclareRobustCommand\({% \relax\ifmmode\@badmath\else$\fi}% \DeclareRobustCommand\){% \relax\ifmmode\ifinner$\else\@badmath\fi\else \@badmath\fi}\makeatother after \begin{document} – touhami Oct 18 '15 at 19:08
  • excuse me, do you think it good template? – touhami Oct 18 '15 at 19:15
  • 1
    Sorry for being silent so long, I was trying to put my template into ShareLaTeX which I finally managed. Here it is: https://www.sharelatex.com/project/5623f19368d179c93909d251 – sahin Oct 18 '15 at 19:26
  • 2
    Ok, so the problem is certainly caused by \def\({\left(} and \def\){\right)}. I think you should change those in order to get back the usual \( and \) behaviour. – Wamseln Oct 18 '15 at 19:32
  • 3
    It is definitely not a good template. It is using obsolete and deprecated packages. It is loading things in the wrong order. It is loading things multiple times. It is setting manually what would be better managed by a package designed for the purpose. And it redefines the standard markup for inline maths mode!! At the very least, delete lines 59 and 60. Better, don't use it at all. – cfr Oct 18 '15 at 19:32
  • 1
    epsfig, subfigure are obsolete and ought not be used. Page layout dimensions: use geometry or a similar package rather than manual settings. Tow letter font switches are 20+ years deprecated and ought not be used in LaTeX code. Font switches do not take an argument. Almost never should \centerline be used in current LaTeX. Setting \parskip by hand is bad. If you really need this, use parskip. Don't use maths mode for text superscripts - there are better ways these days. If you must change the line spread, use setspace. – cfr Oct 18 '15 at 19:37
  • 2
    Also, eqnarray shouldn't be used. Use align from amsmath instead. – Bernard Oct 18 '15 at 19:39
  • Sorry. I didn't mean to edit it. I changed it without thinking. Why on earth did it let me? – cfr Oct 18 '15 at 19:43
  • Thanks @Wamseln, now I see the reason of the error, I'll accept it as an answer if you post. – sahin Oct 18 '15 at 19:43
  • @cfr, I'm not an expert in these things. I borrowed the code from one of my colleagues and didn't examined it deeply. Your comments are valuable. I will keep them as a side note for now and try to understand them for the future reference. Thanks for sparing time to write so long, I appreciate it. – sahin Oct 18 '15 at 19:47

1 Answers1

5

Here's an attempt to clean things up a bit. More could be done, but I think this modifies the worst features of the original template.

\documentclass[12pt,letterpaper]{article}
\usepackage{mathtools,amssymb}
\usepackage{graphicx,xcolor}
\usepackage{verbatim}
\usepackage{fancybox}
\usepackage{ulem}
\usepackage{enumitem}
% \usepackage{subfigure}% obsolete! use subfig or, better, subcaption
\usepackage{bbm}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\newlength\normalparindent
\setlength\normalparindent\parindent
\usepackage{parskip,setspace}
\setstretch{1.3}
\usepackage[textwidth = 6.5in, textheight = 8.5in, marginparwidth=0pt, marginparsep=0pt, headheight=0pt, headsep=0pt, left=1in, top=1.2in]{geometry}
\usepackage{titling}

\newcommand{\Comment}[1]{{}}
\definecolor{MyDarkBlue}{rgb}{0.15,0.15,0.45}
\usepackage[linktocpage=true]{hyperref}
\hypersetup{
  colorlinks=true,
  citecolor=MyDarkBlue,
  linkcolor=MyDarkBlue,
  urlcolor=MyDarkBlue,
  pdfauthor={John Smith},
  pdftitle={SUBJECT},
  pdfsubject={hep-th}
}

% use align rather than eqnarray
\newcommand{\nn}{\nonumber}

\newcommand{\gmu}{\gamma^\mu}
\newcommand{\gnu}{\gamma^\nu}
\newcommand{\glmu}{\gamma_\mu}
\newcommand{\gf}{\gamma^5}
\newcommand{\Tr}{\text{Tr}}
\newcommand{\qb}{\mathbf{q}}
\newcommand{\pb}{\mathbf{p}}
\newcommand{\kb}{\mathbf{k}}
\newcommand{\xb}{\mathbf{x}}
\newcommand{\pd}{(2\pi)^d}
\newcommand{\intx}{\int d^d \mathbf{x}\ }

\newcommand{\la}{\langle}
\newcommand{\ra}{\rangle}
\newcommand{\lb}{\left[}
\newcommand{\rb}{\right]}
\newcommand{\half}{\frac{1}{2}}
\newcommand{\pf}{(2\pi)^4}
\newcommand{\intkd}{\int \frac{d^Dk}{(2\pi)^D}\ }
\newcommand{\intpd}{\int \frac{d^Dp}{(2\pi)^D}\ }
\newcommand{\intpdo}{\int \frac{d^{D-1}k}{(2\pi)^{D-1}}\ }
\newcommand{\intl}{\int \frac{d^4l}{(2\pi)^4}\ }
\newcommand{\intld}{\int \frac{d^dl}{(2\pi)^d}\ }
\newcommand{\intle}{\int \frac{d^4l_E}{(2\pi)^4}\ }
\newcommand{\intp}{\int d^d \mathbf{p}\ }
\newcommand{\wsp}{\omega_{\mathbf{p}}}
\newcommand{\intpp}{\int \frac{d^d \mathbf{p}}{\sqrt{\pd 2\wsp}}\ }

\title{SUBJECT\thanks{This is a title.}}
\author{John Smith\textsuperscript{\itshape a,}\thanks{E-mail address: \Comment{\href{mail@mail.edu}}{\url{mail@mail.edu}}}}
\date{}
\pretitle{\begin{center}\LARGE\bfseries}% Note that your original settings do not get bold small-caps and would not do so even if this shape existed in bold for this font. If you want small-caps, change \bfseries to \scshape
\posttitle{\par\end{center}\vskip 10mm}
\preauthor{\begin{center}\large\scshape}
\postauthor{\par\end{center}\vskip 10mm}
\predate{}
\postdate{}
\renewcommand\maketitlehookc{\begin{center}\itshape\textsuperscript{a}Department,\par Address\par\end{center}\vskip 10mm}

\numberwithin{equation}{section}

\begin{document}
\setlength\parindent\normalparindent% Not at all clear this is wise with skip between paragraphs as well, but if you must, you must...
\maketitle\thispagestyle{empty}

\begin{abstract}
Abstract goes in here.
\end{abstract}
\clearpage

\tableofcontents
\clearpage

\section{Introduction}

\section{Conclusions}

\section{Acknowledgements}

\appendix

\section{Appendix 1}

\addcontentsline{toc}{section}{References}
\input{references.tex}

\end{document}

Modified template

cfr
  • 198,882