6

I am new to LaTeX and have a problem with the line

The difference is that the signing key \emph{x} is split into two pieces, \begin{math}
\emph{x_{L}}\end{math} and \begin{math}\emph{x_{R}}\end{math} and are both elements of the 
\begin{math}\textbf{Z}_{q}\end{math}.

I get the error

! Missing $ inserted.
<inserted text> 

I am a little confused why I am getting this error since I have put the _ in a math section. Any help would be great. Thanks!

diabonas
  • 25,784
tpar44
  • 195
  • 6
    Welcome to TeX.sx! \emph is a text-mode command, so even though it's within a math-mode environment, a _ will be recognized as text. in fact, unless you've done something unusual, the math will be set automatically in italic, so there should be no need for the \emph. also, a shorter way to input in-line math is \( x_L \) and you don't need to bury single-letter subscripts in braces. these things will come with time. – barbara beeton Sep 26 '12 at 16:41

3 Answers3

7

\emph{} starts in text mode, so its parameter must be text, not math. So you need to go into math mode again within the \emph{}, as in \emph{$x_{L}$}.

enter image description here

Notes:

  • I usually just use $...$ for inline math constructs (See References below).
  • Also I am not sure why you want to use \emph{} within math mode, unless you have a special definition of \emph{}.
  • I have also replaced \textbf{} with \mathbf{}.

References:

Code:

\documentclass{article}

\begin{document} The difference is that the signing key $x$ is split into two pieces, $x_{L}$ and $x_{R}$ and are both elements of the $\mathbf{Z}_{q}$. \end{document}

Peter Grill
  • 223,288
3

For inline math you should use $ your equation $ or \( your equation \). But \(...\) is fragile. loading fixltx2e makes it robust. For display equation without number, use \[ equation \] or

\begin{equation*}
.
.
.
\end{equation*}

For numbered equations, use

\begin{equation}
.
.
.
\end{equation}

A MWE:

\documentclass{article}
\usepackage{amsmath} 

\begin{document}
The difference is that the signing key $x$ is split into two pieces, 
$x_{L}$ and \(x_{R}\) and are both elements of the $x_{L}$

\[\mathbf{Z}_{q}.\]

\begin{equation}
    \mathbf{Z}_{q}
\end{equation}

\begin{equation*}
    \mathbf{Z}_{q}
\end{equation*}

\end{document}

enter image description here

1

Why you use \emph{} for math?

$x_L$ and $\mathbf{Z}_q$ will do the same in simplest form without error.

egreg
  • 1,121,712
Aydin
  • 1,983
  • It looks like this is the only answer actually answering the implicit question (implied by the title, as the question is not clear): how to emphasize math in latex. +1. That said mathbf renders poorly, but that's not your fault! – mins Mar 12 '23 at 10:31