I'm trying to make a table with the headers bottom justified, and the rest top justified. I can get the headers right, but when I try to top justify any of the remaining rows, it messes up the headers. I'd like to do it in Lyx, because the actual table I'm using is rather large with long text, and it is much easier in a table editor. Here's a MWE:
#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\begin_preamble
\usepackage{makecell,}
\renewcommand\theadfont{\normalsize\bfseries}
\renewcommand\theadalign{lb}
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
#1\ignorespaces
}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\newcolumntype{M}{>{\varwidth[t]{3cm}}l<{\endvarwidth}}
\end_preamble
\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
\use_microtype false
\use_dash_ligatures true
\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 false
\justification true
\use_refstyle 1
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 0in
\topmargin 0.5in
\rightmargin 0in
\bottommargin 0.5in
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\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 Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
begin{centering}
\backslash
ra{1.3}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="8">
<features booktabs="true" tabularvalignment="middle">
<column alignment="left" valignment="top" width="1.5in">
<column alignment="center" valignment="top" width="0.6in">
<column alignment="center" valignment="top" width="0.6in">
<column alignment="center" valignment="top" width="0.6in">
<column alignment="left" valignment="top" width="1.5in">
<column alignment="center" valignment="top" width="0.6in">
<column alignment="center" valignment="top" width="0.6in">
<column alignment="center" valignment="top" width="0.6in">
<row>
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\noindent
\series bold
One Line Heading
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\noindent
\series bold
Three Line Heading
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\noindent
\series bold
Three Line Heading
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\noindent
\series bold
2 Line Heading
\end_layout
\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\noindent
\series bold
One Line Heading
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\noindent
\series bold
2 Line Heading
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\noindent
\series bold
2 Line Heading
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\noindent
\series bold
Three Line Heading
\end_layout
\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
Two line text that is top aligned
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
One
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
One
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
One
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
Three line text that is top aligned that wraps around and keeps going
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
Three Lines of Text
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
One
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
Two Lines
\end_layout
\end_inset
</cell>
</row>
</lyxtabular>
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
end{centering}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\end_layout
\end_body
\end_document
Here's the result:
Note that the two wider columns are left-justified. In one version of the document, on one table, I was able to top justify everything, and hit <Ctrl-Enter> above headings that needed moving down, but currently, it just eats those characters :/. Putting a vertical space above the titles didn't yield the right result either. Here's somebody doing the same thing, but not in Lyx:
However, if I add the following to the preamble:
\usepackage{makecell,}
\renewcommand\theadfont{\normalsize\bfseries}
\renewcommand\theadalign{lb}
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
#1\ignorespaces
}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\newcolumntype{M}{>{\varwidth[t]{3cm}}l<{\endvarwidth}}
and add the ERT \ra{1.3}
just above the table, and top-justify the data row, the header row is top-justified, too. This probably has to do with the fact that Lyx doesn't mark headers with the \thead
environment. It is not possible to add ERT before and after a single row in Lyx (without specifying the thole table as ERT). It is not a good general solution to bottom-justify the tallest cells, as suggested on their wiki: LyX wiki | LyX / Tables, since 1) the tallest cells alone aren't enough, and one must bottom justify the one and two line cells to bottom justify the whole row; and 2) by the time you bottom justify the one and two line header cells you need to, and top justify the one and two line cells in the rest of the table you need to, you've specified different vertical alignments for the same column - thereby messing up the header row.
Since some people, such as myself, will be happy to have headers on all tables, ideally, someone might find a solution that applies to all tables. I would also be happy to add code to each table to make this happen. It would be nice to have a document-wide and a table-specific solution, if both can be readily worked out, for both types of usages; but a table-specific solution alone would be great, in and of itself.