# Why is the following LaTeX code invalid?

I am trying to compile a document using lyx and the following line:

$Encrypted(k_\left\{subcontractor,airplane\right\}, softwareBytes | HMAC(softwareBytes))$


gives an error as if the first and second squiggly brackets are not closed even though running the same code here displays the intended output.

Why?

Edit:

I've added the subscript braces:

$Encrypted(k_{\left\{subcontractor,airplane{\right\}}}, softwareBytes | HMAC(softwareBytes))$


In the online editor it works. In lyx the following errors are given:

Missing } inserted.
Extra }, or forgotten $ • You have to use braces for subscripts: _{\left\{ \right\}} – Sigur Jan 26 '16 at 12:48 • I have added them but the syntax error persists. The code is still valid in the online editor. – Sebi Jan 26 '16 at 12:55 • Now it looks like you have an extra pair of braces around the \right\} – darthbith Jan 26 '16 at 12:56 • Maybe you could be interested in \text{subcontractor} from amsmath package. – Sigur Jan 26 '16 at 13:01 • please do not edit the question to contain the answer, the answer should be posted as an answer. – David Carlisle Jan 26 '16 at 13:08 ## 1 Answer the error message is due to missing braces around the subscript, but other non-reported errors are use of math-italic for words, and use of \left,\right in this context also \mid gives perhaps better spacing than | \documentclass{article} \begin{document}$\mathrm{Encrypted}(k_{\{ \mathrm{subcontractor},\mathrm{airplane}\}}, \mathrm{softwareBytes} \mid \mathrm{HMAC}(\mathrm{softwareBytes}))\$

\end{document}

• May be \operatorname{Encrypted} and \operatorname{\textsc{hmac}} might be liked (or declaring \DeclareMathOperator\Encrypted{Encrypted} and \DeclareMathOperator\HMAC{\textsc{hmac}}). – Manuel Jan 26 '16 at 13:19
• @Manuel I wondered about doing that but "one thing at a time" :-) – David Carlisle Jan 26 '16 at 13:24