2

I am using \begin{equation} to write equation but it is in italic. How do i disable it ? The other threads all not for \begin{equation}. everything inside it is green

\begin{equation} \label{eq:oa}
Overlap Area = \frac{Area (Detection \cap Ground Truth)}{Area (Detection \cup Ground Truth )}
\end{equation}

My main code below

\documentclass[pdftex,12pt,a4paper]{report}

\usepackage[top=3cm, bottom=3cm, left=3.5cm, right=3cm]{geometry}

% graphics images
\usepackage[pdftex]{graphicx}
\usepackage[toc,page]{appendix}
\usepackage{slashbox}

% 1.5 line spacing
\usepackage{setspace}
\usepackage{tabu}
\usepackage{tabularx}
\onehalfspacing

% maths symbols
%\usepackage{amsmath}
\usepackage[math-style = upright]{unicode-math}

% table package
\usepackage{multirow}

% citation style
\usepackage[colorlinks=true,linkcolor=blue]{hyperref}%
\makeatletter
\let\Hy@linktoc\Hy@linktoc@none
\makeatother

\usepackage[square,sort,comma,numbers]{natbib}
\usepackage{amsfonts}

%\renewcommand{\chaptername}{}

\usepackage{tikz,colortbl}
\usetikzlibrary{calc}
\usepackage{zref-savepos}

\usepackage[bf,small,tableposition=top]{caption}
\usepackage{subfig}
\usepackage{float}
\usepackage{url}

\begin{document}

% cover
\input{cover_report.tex}

% title page
%\input{title_report.tex}

% abstract
\setcounter{page}{1}
\pagenumbering{roman}
\input{abstract.tex}

% acknowledgement
\input{acknowledgements.tex}

% table of content
\tableofcontents
\addcontentsline{toc}{chapter}{Contents}

% list of tables
%\listoftables
%\addcontentsline{toc}{chapter}{List of Tables}

% list of figures
%\listoffigures
%\addcontentsline{toc}{chapter}{List of Figures}

% intro chapter
\cleardoublepage
\pagenumbering{arabic}
\input{intro.tex}
\input{literature.tex}
%\input{propose.tex}
\input{module_design.tex}
\input{training.tex}
\input{results.tex}
\input{conclusion.tex}
% references
\bibliographystyle{plainnat}
\bibliographystyle{unsrt}
\bibliography{fyp}

% appendix
%\input{appendix.tex}
\end{document}
Kong
  • 2,313
  • 1
    Could you show a whole compilable code? Usually, the standard for mathematical writing is that variables are set in italic. – Bernard Jul 05 '16 at 11:41
  • Welcome to TeX.SX! Of course in the math environments the variables are in italic, but operators are in upright shape. Both use fonts for math (usually are part of used fonts or is the same) ... If you not like to write equations as other do, you need to change math fonts. – Zarko Jul 05 '16 at 11:42
  • You can use the unicode package with the option \usepackage[math-style = upright]{unicode-math} (compile with xelatex) – alwaysask Jul 05 '16 at 11:45
  • 2
    If you are trying to write words inside a math environment, you could use \text{you text} from amsmath-package. – Runar Jul 05 '16 at 11:47
  • Hi sorry. I have edited my post to include my equation – Kong Jul 05 '16 at 11:51
  • 1
    Unrelated note: You usually don't want to specify the driver (pdftex) for the graphicx package, so remove the pdftex argument there, and also from the documentclass settings. graphicx detects which driver to use. (And if you're using unicode-math, then you're not using pdftex anyway, so it's even the wrong driver I guess.) – Torbjørn T. Jul 05 '16 at 12:11
  • @RunarTrollet, do you mind to convert your comment to an answer? – Zarko Jul 05 '16 at 12:15

1 Answers1

6

Inside a math environment, LaTeX assumes that every letter is a variable, and will typeset it in a math font with italics, and ignore all spaces.

To tell LaTeX that you are typing in text, you could use the text{} command from the amsmath-package. Here I load the mathtools-package, which in turn loads amsmath.

You could also use \textrm{} without loading any packages, but I recommend using \text{}. Have a look at What is the "correct" way of embedding text into math mode?

Here, you mix text with math symbols, like the \cap. These symbols need to be typeset in math mode. You can do this by surrounding the symbol with \( and \) , like this: \( \cap \). You might have seen a TeX-equivalent of this, where $-signs were used, but this is against recommendations and the old way of doing it. For more information about this, see: Are \( and \) preferable to $?

Output

enter image description here

Code

\documentclass[11pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{equation} \label{eq:oa}
\text{Overlap Area} = \frac{ \text{Area (Detection \(\cap\) Ground Truth)} }{ \text{Area (Detection \(\cup\) Ground Truth)} }
\end{equation}
\end{document}
Runar
  • 6,082
  • or \frac{\text{Area (Detection}\cap\text{ Ground Truth)}}{\text{Area (Detection}\cup\text{Ground Truth)}} ? – Zarko Jul 05 '16 at 12:40
  • @Zarko I think the spacing would be wrong, even if you were consistent with the space introduced before Ground, and either removed it in both or added it in both. – Runar Jul 05 '16 at 12:46
  • 2
    @Zarko \Area(\text{Detection} \cap \text{Ground Truth}) with \DeclareMathOperator\Area{Area}. Altough I've been lately thinking that \text is not the right tool for this job. I would use \mathrm or \textnormal when needed (or better, a symbolic and semantic macro that would ease the change of the ouput just changing the definition). – Manuel Jul 05 '16 at 12:47
  • @Manuel It could be interesting to see your take on this in the question I linked to in my post. Consider making an answer there. Again, link to post: What is the “correct” way of embedding text into math mode? – Runar Jul 05 '16 at 12:53
  • Thanks for the answer runar ! Managed to get it to work after following your post and some other suggestions from the others. I'm very new to latex. I downloaded this template from http://www.ntu.edu.sg/home/aseschng/teaching/teaching.html for my project so all the commands and syntax feels new – Kong Jul 05 '16 at 12:58