# LYX equation numbers not synchronized properly between editor and output when mixing WYSIWIG with LATEX equations

I'm writing a paper in LYX. All my equations are numbered and entered with the built-in wysiwyg math editor, except for one which I had to enter as LATEX. This messed up the numbering in the editor which didn't count the LATEX equation, but the output pdf was fine. In the output pdf file equation numbers are larger by 1 than the equations in the editor after the LATEX equation. There must be a different counter in the lyx editor for equations than in the LATEX output. How can I synchronize them properly? For example, can I write a macro to add 1 to the editor's counter without changing the LATEX counter?

• welcome to tex.sx. although there are people here who are familiar with lyx (i'm not), this seems a question more suited for asking directly on the lyx site. (it's a quite interesting question!) – barbara beeton Oct 11 '17 at 22:11
• Why did you need to write that one equation as code? (I.e., what was it you couldn't do via the GUI?) – Torbjørn T. Oct 11 '17 at 22:23
• Similar to the comment above, note that you can go to Edit > Paste Special > Paste from LaTeX when you paste LaTeX into LyX. This will attempt to turn it into native LyX format, which would correct the equation numbering. – scottkosty Oct 11 '17 at 23:20
• I had a long equation that spilled over onto another line. When I tried various methods to break the line into two in LYX it always turned out that something was wrong or ugly with the format. The two lines of the equation looked too close together for my aesthetic sense. So I resized the two lines, and put an extra 2mm vertical space between them. Now they look much better, but I have the equation number synchronization problem that I don't like. – Mark Davidson Oct 11 '17 at 23:32
• May I ask exactly how you did it? For example, was it \begin{multlined} first part \\[2mm] second part \end{multlined}? (Asking as I was wondering if there might be other ways of achieving the same in LyX.) – Torbjørn T. Oct 12 '17 at 12:31

Technically this doesn't answer your question, so I can delete it if you'd like me to. But as an extension of my last comment: At the end of this post you'll find a sample .lyx file. It demonstrates your method, as well as using either a gathered or an align environment instead of array. Both those environments are available via the GUI, either via the Insert --> Math menu, or by right clicking in an equation and looking under Insert.

Compared to the array, the increase in font size isn't necessary because it doesn't use \textstyle (or whatever array does), and the [2mm] isn't necessary because there is more space between the lines by default than what array does.

Here is a screenshot showing the three approaches. Personally I'd probably use the third one. Note I replaced the \mid with \biggr|.

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\save_transient_properties true
\origin unavailable
\textclass article
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false

\begin_body

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout

\backslash
large
\end_layout

\begin_layout Plain Layout

\backslash
begin{equation}
\end_layout

\begin_layout Plain Layout

\backslash
begin{array}{c}
\end_layout

\begin_layout Plain Layout

F^{
\backslash
mu
\backslash
nu}(x)=
\backslash
frac{q}{V_{B}(s)
\backslash
cdot
\backslash
left(x-X_{B}(s)
\backslash
right)}
\backslash

\backslash
[2mm]
\end_layout

\begin_layout Plain Layout

\backslash
times
\backslash
frac{d}{ds}
\backslash
left[
\backslash
frac{
\backslash
left(x-X_{B}(s)
\backslash
right)^{
\backslash
mu}V_{B}^{
\backslash
nu}(s)-
\backslash
left(x-X_{B}(s)
\backslash
right)^{
\backslash
nu}V_{B}^{
\backslash
mu}(s)}{V_{B}(s)
\backslash
cdot
\backslash
left(x-X_{B}(s)
\backslash
right)}
\backslash
right]
\backslash
mid_{s=s_{r}}
\end_layout

\begin_layout Plain Layout

\backslash
end{array}
\end_layout

\begin_layout Plain Layout

\backslash
end{equation}
\end_layout

\begin_layout Plain Layout

\backslash
normalsize
\end_layout

\end_inset

\end_layout

\begin_layout Standard
Alternative approach 1:
\begin_inset Formula
$$\begin{gathered}F^{\mu\nu}(x)=\frac{q}{V_{B}(s)\cdot\left(x-X_{B}(s)\right)}\\ \times\frac{d}{ds}\left[\frac{\left(x-X_{B}(s)\right)^{\mu}V_{B}^{\nu}(s)-\left(x-X_{B}(s)\right)^{\nu}V_{B}^{\mu}(s)}{V_{B}(s)\cdot\left(x-X_{B}(s)\right)}\right]\biggr|_{s=s_{r}} \end{gathered}$$

\end_inset

\end_layout

\begin_layout Standard
Alternative approach 2:
\begin_inset Formula
\begin{aligned}F^{\mu\nu}(x) & =\frac{q}{V_{B}(s)\cdot\left(x-X_{B}(s)\right)}\\ & \qquad\times\frac{d}{ds}\left[\frac{\left(x-X_{B}(s)\right)^{\mu}V_{B}^{\nu}(s)-\left(x-X_{B}(s)\right)^{\nu}V_{B}^{\mu}(s)}{V_{B}(s)\cdot\left(x-X_{B}(s)\right)}\right]\biggr|_{s=s_{r}} \end{aligned}

\end_inset

\end_layout

\end_body
\end_document

• Torbjorn, Thanks a lot. I like your third example. I'll use it in my paper. That solves my problem. – Mark Davidson Oct 13 '17 at 5:01