# Using “aligned” environment with optional argument in LyX

I would like to align the bullet point to the first line of equations in an "aligned" environment, rather than the default of a middle vertical alignment (see image). I know this can be achieved by adding the [t] optional argument to \begin{aligned}, but there seems no easy way to do this in LyX. How can I make this work without typing everything in raw latex code (ERT)?

• Welcome to TeX.SX! Did you consider not using LyX? – egreg Jul 20 '17 at 16:03
• Optional argument to \begin{itemize} or to \item? If the second, you can go to Insert > Custom Item. – scottkosty Jul 20 '17 at 17:15
• @egreg I do use tex editor for collaborative projects, but would prefer to keep LyX for stuff where I don't need to share the code as I still find the instant math/table display indispensable. @scottkosty It should be \begin{aligned}[t]; I have updated the question to make this clear. – David L Jul 21 '17 at 2:53
• @egreg Is it a general advice or do you have a non-LyX solution? In the second case, I think the OP could use ERT. – CarLaTeX Jul 21 '17 at 6:03
• There is a way to do it with latex code (that is, using \begin{aligned}[t] as I mentioned) - the problem is really that my equations are quite a lot more complicated than 3y+4=22 and it will be a mess when viewed in the LyX editor if I type everything in ERT. I just need LyX to put in that [t] at the appropriate place. – David L Jul 21 '17 at 15:29

# solution 1 (recommended):

1. Place the cursor in the aligned environment.
2. Go to Edit > rows & columns > top.

Or see the shortcut listed in when you do the menu, which with the default cua bind is: Alt + M, W T. The shortcut works with "T" for top, "B" for bottom, or "M" for middle.

Note that the LyX display and PDF output both change:

# solution 2 (hackish, not recommended, but more general):

Alternatively, you can open the .lyx file in a text editor and add the [t]. This is not recommended because you should only use LyX to edit .lyx files. But in the case of math, sometimes it works. If you follow this approach, you should always open the resulting .lyx file from the terminal (if on Linux, just type lyx file.lyx) to see if there are any parsing errors that show up (these are not reported in the GUI).

Here is the resulting .lyx file, in 2.2.x format:

#LyX 2.3 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 1
\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 Itemize
\begin_inset Formula $5x+6=10$
\end_inset

\end_layout

\begin_layout Itemize
\begin_inset Formula \begin{aligned}[t]3y+4 & =22\\ 3y & =18\\ y & =6 \end{aligned}
\end_inset

\end_layout

\end_body
\end_document

• Thanks! It's easy to overlook options in the Windows toolbar. With this, I find that it is worth bringing out the Table toolbar at the bottom (View > Toolbars > Table (auto)) to avoid going through the menu search. – David L Jul 22 '17 at 3:58
• As an alternative to editing the .lyx file externally, you can copy the part of the math expression from the LyX window to an external editor, do the edit there and then paste it back into the LyX math environment. This will be parsed automatically, without risk of breaking the whole file or need to reopening LyX. – hife Feb 13 '20 at 22:22