1

I have code like:

N examples,each (input $x_n$, label $y_n$) $\in\mathcal{X} x\left{1,2,\dots,K,\right}$ and cost matrix $C\in\R^{KxK}$

Which I am using to replicate:

enter image description here

But for some reason the code is not rendering - I am using amsmath. The error I get is:

1
  • 2
    You need \left\{ and \right\} (note the backslash before the curly brackets). However just \{ and \} alone (no \left and \right) would be preferable here.
    – Au101
    Aug 31 '16 at 22:49
5

Your main issue is that you need \left\{ and \right\} (note the \ before the curly brackets). However just \{ and \} alone (no \left and \right) would be preferable here. See these questions for more:

If you fix this problem, your code will compile (assuming you have already defined \R as \mathbb{R} - it is not defined by default). However, there are other problems with your code, try this:

\documentclass{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[usenames]{color}
\newcommand{\green}[1]{\textcolor{green}{#1}}

\begin{document}

\noindent% just for the example
$N$ examples, each $\text{(input $\mathbf{x}_{n}$, label $y_{n}$)} \in
\mathcal{X} \times \{1, 2, \dots, K\}$
\[
  \boxed{\text{and cost matrix $\mathcal{C} \in \mathbb{R}^{K \times K}$}}
\]
---will assume
$\mathcal{C}(y, y) = \green{0} = \min_{1 \leq k \leq K} \mathcal{C}(y,
k)$

\end{document}

enter image description here

Your main problem is using x for \times.

For more information on why you were getting an error, allow me to plug my own answer over here: https://tex.stackexchange.com/a/253082/16968. Because \left and \right require a printable delimiter after them, you need to use \{ and \} (which produce the { and } delimiters) not { and } which are used to delimit arguments to LaTeX commands not to print delimiters in the actual output.

2
  • I removed the call to the package parskip, that's not necessary for the code. Its presence could be misunderstood as essential for solving the OP's issue, besides being a disputable typographic practice.
    – egreg
    Sep 1 '16 at 8:25
  • @egreg Thanks, I just found it the easiest way to reproduce the clear line above and below the boxed line in the OP's example, but your approach is good :)
    – Au101
    Sep 1 '16 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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