[Tex/LaTex] Lyx Table Vertical Alignment

lyxtablesvertical alignment

How can I achieve the table layout shown in the image below using the Lyx editor please?

I would like to have the first and last column contents vertically aligned to the top while the 3rd and 4th column contents should be vertically aligned to the middle.

I read something about changing the cells to multicolumn but it seems that the vertical alignment settings of the cell containing the most text overrides all the other cells in the same row.

Thanks in advance for your help

UPDATE: Below is the sample table code. All cells are vertically middle aligned.

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\begin_header
\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 "lmodern" "default"
\font_sans "lmss" "default"
\font_typewriter "lmtt" "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 true
\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 true
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 2cm
\topmargin 2cm
\bottommargin 2cm
\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
\end_header

\begin_body

\begin_layout Section*
Sample Table
\end_layout

\begin_layout Standard
\begin_inset VSpace smallskip
\end_inset


\end_layout

\begin_layout Standard
\noindent
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="6" columns="5">
<features tabularvalignment="top">
<column alignment="center" valignment="middle" width="1cm">
<column alignment="left" valignment="middle" width="7cm">
<column alignment="center" valignment="middle" width="2cm">
<column alignment="center" valignment="middle" width="1.2cm">
<column alignment="center" valignment="middle" width="2.5cm">
<row>
<cell multicolumn="1" alignment="center" valignment="middle" topline="true" bottomline="true" leftline="true" usebox="none" width="8cm">
\begin_inset Text

\begin_layout Plain Layout

\series bold
Title 1
\end_layout

\end_inset
</cell>
<cell multicolumn="2" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="middle" topline="true" bottomline="true" leftline="true" usebox="none" width="2cm">
\begin_inset Text

\begin_layout Plain Layout

\series bold
Title 2
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\series bold
Title 3
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\series bold
Title 4
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="middle" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="left" valignment="middle" topline="true" bottomline="true" rightline="true" usebox="none" width="7cm">
\begin_inset Text

\begin_layout Plain Layout
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 Vivamus quis lobortis lectus.
 Curabitur egestas faucibus purus.
 Proin sem risus, imperdiet ac imperdiet eget, elementum a libero.
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="bottom" topline="true" bottomline="true" rightline="true" usebox="none" width="2cm">
\begin_inset Text

\begin_layout Plain Layout
1
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none" width="1.2cm">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Lorem Ipsum
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
2
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="left" valignment="middle" bottomline="true" rightline="true" usebox="none" width="7cm">
\begin_inset Text

\begin_layout Plain Layout
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 Vivamus quis lobortis lectus.
 Curabitur egestas faucibus purus.
 Proin sem risus, imperdiet ac imperdiet eget, elementum a libero.
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none" width="2cm">
\begin_inset Text

\begin_layout Plain Layout
2
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
7
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="middle" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Lorem Ipsum
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="middle" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 Vivamus quis lobortis lectus.
 Curabitur egestas faucibus purus.
 Proin sem risus, imperdiet ac imperdiet eget, elementum a libero.
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none" width="2cm">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
8
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="middle" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Lorem Ipsum
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="middle" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 Vivamus quis lobortis lectus.
 Curabitur egestas faucibus purus.
 Proin sem risus, imperdiet ac imperdiet eget, elementum a libero.
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none" width="2cm">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
9
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="middle" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Lorem Ipsum
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" rightline="true" usebox="none" width="1cm">
\begin_inset Text

\begin_layout Plain Layout
5
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="middle" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 Vivamus quis lobortis lectus.
 Curabitur egestas faucibus purus.
 Proin sem risus, imperdiet ac imperdiet eget, elementum a libero.
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none" width="2cm">
\begin_inset Text

\begin_layout Plain Layout
5
\end_layout

\end_inset
</cell>
<cell multicolumn="1" alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none" width="1.2cm">
\begin_inset Text

\begin_layout Plain Layout
10
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="middle" bottomline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Lorem Ipsum
\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\end_body
\end_document

Best Answer

Just now I managed to do it thanks to the tips at LyX wiki | Lyx / Tables

Basically you set the vertical alignment of the row cell with the most text to the default one you want (in my case it was middle and the cell had 5 lines). Then, if you have, for example, the number 1 in a cell to be vertically aligned at the top, you:

  • Type 1
  • Press Enter and insert an Interword Space
  • Press Enter again and insert another Interword Space

So now you have 3 lines in total in that cell (3 is the center line when you have another cell with 5 lines)

Finally, you set the vertical alignment to the opposite of what you want. Therefore I wanted the 1 to go to the top so I set the vertical alignment to bottom.

Hope this helps someone.