4

I've notices that when i want to decrease space between rows in LYX (using More->Settings->Row Setting), I can't select Row Setting? what's the problem?

I know how to change the Tex code, but i wonder what the problem with LYX options?

  • I don't see any spacing options at all in the table settings, and under Row settings the only choice is that for multi row cells. – Torbjørn T. Oct 23 '15 at 18:06
  • Actually, ne either. How then can change the space, using just TEX code? – user90561 Oct 23 '15 at 18:31
  • Offset is not the same as spacing, and that is related to multirow, it adds a vertical offset for the content in the multirow cell. How were you planning to do it with LaTeX code? – Torbjørn T. Oct 23 '15 at 18:31
  • Yes, I got it. I already inserted Table (using LYX option). I was thinking, either to transform it to the TEx code, and then make changes there (will it work???), or should i write tex code myself forgetting about LYX tables options? I found easy to put a table in the text using lyx, but not unfortunately not to edit it. – user90561 Oct 23 '15 at 18:33
  • You could do that. If you're thinking about 'global' changes using e.g. \arraystretch or \extrarowheight (cf. extrarowheight vs arraystretch), you need only add a \setlength statement in an ERT. If you were thinking of \\[1cm] I don't know how to do that. – Torbjørn T. Oct 23 '15 at 18:41
4

First of all, LyX isn't a LaTeX editor, and if you want complete control of the code of your table, write it in an ERT (Insert --> TeX Code), or in a separate text-file which you can add to LyX with Insert --> File --> Child document, setting Include type to Input.

I'm not sure why you want to decrease the space in the first place, but then I don't know the context. Of course, if you happen to have set the line spacing globally or for just the paragraph where the table is, that will affect the table rows as well, and in that case you should open the paragraph settings (right click right next to table --> Paragraph settings), and set the line spacing to Default, before doing anything else.

There are two parameters you can change to modify line spacing for an entire table, they are \extrarowheight and \arraystretch, see extrarowheight vs arraystretch. To use them in LyX you will need to do Insert --> TeX Code right before the table, and write \setlength{\extrarowheight}{<some length>} or \renewcommand{\arraystretch}{<some number>}. Note that the latter requires the array package, so will also need to go to Document --> Settings --> LaTeX preamble, and add \usepackage{array}.

Note that if not placed within a surrounding environment (such as \begin{table} ... \end{table}) those settings will apply to all following tables, which you may or may not want. In the example below I added a brace pair { ... } around the modification and tabular.

Here's an example .lyx file showing some of this (screenshot below). Copy the text to an empty text file, and save it as something.lyx, then you should be able to open it in LyX.

#LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass article
\begin_preamble
\usepackage{array}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing double
\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
\end_header

\begin_body

\begin_layout Subsubsection*
Default settings
\end_layout

\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="1">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top">
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Some text
\end_layout

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

\begin_layout Plain Layout
More of the same
\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
Aaand, yet more.
\end_layout

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

\end_inset


\end_layout

\begin_layout Subsubsection*
With double spaced lines in paragraph
\end_layout

\begin_layout Standard
\paragraph_spacing double
\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="1">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top">
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Some text
\end_layout

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

\begin_layout Plain Layout
More of the same
\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
Aaand, yet more.
\end_layout

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

\end_inset


\end_layout

\begin_layout Subsubsection*
Negative extrarowheight
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout

{
\backslash
setlength
\backslash
extrarowheight{-2pt}
\end_layout

\end_inset


\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="1">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top">
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Some text
\end_layout

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

\begin_layout Plain Layout
More of the same
\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
Aaand, yet more.
\end_layout

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

\end_inset


\begin_inset ERT
status open

\begin_layout Plain Layout

}
\end_layout

\end_inset


\end_layout

\begin_layout Subsubsection*
arraystretch 0.5
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout

{
\backslash
renewcommand
\backslash
arraystretch{0.5}
\end_layout

\end_inset


\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="1">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top">
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Some text
\end_layout

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

\begin_layout Plain Layout
More of the same
\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
Aaand, yet more.
\end_layout

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

\end_inset


\begin_inset ERT
status open

\begin_layout Plain Layout

}
\end_layout

\end_inset


\end_layout

\begin_layout Subsubsection*
ERT
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
begin{tabular}{|c|}
\end_layout

\begin_layout Plain Layout


\backslash
hline
\end_layout

\begin_layout Plain Layout

Some text 
\backslash

\backslash
[0.5cm] 
\backslash
hline
\end_layout

\begin_layout Plain Layout

More of the same 
\backslash

\backslash

\backslash
hline
\end_layout

\begin_layout Plain Layout

Aand, yet more 
\backslash

\backslash

\backslash
hline
\end_layout

\begin_layout Plain Layout


\backslash
end{tabular}
\end_layout

\end_inset


\end_layout

\end_body
\end_document

enter image description here

  • Thank you very much. This helps a lot. By the way, i have very long table, and i'd like it to be on several pages in pdf file. Unfortunately, it appears only on one sheet. and the rest of the table is just unobservable. What should i do to split the table across pages? is it possible that LYX would do it automatically somehow? – user90561 Oct 26 '15 at 9:13
  • @user90561 In the table settings, go the Longtable tab, and check Use long table. – Torbjørn T. Oct 26 '15 at 9:19
  • It looks, that i cant choose this option. can't click to select that option. should be any packages installed before? or some other problems? – user90561 Oct 26 '15 at 9:27
  • Also, how to spread words in a Table cell ? when i write a long phrase, it just writes lengthway. – user90561 Oct 26 '15 at 9:29
  • @user90561 I have no idea why that might be. The longtable package must be installed, but I would think it was that already. Anyways, ask a new question, and preferably add a minimal .lyx file to it, so that we can try with your setup. Comments are really not the best place for an extended discussion of multiple problems, usually better to ask separate questions. If you set a width for a column, long lines will break. (And if this answer was useful, consider upvoting [by clicking the up-arrow on the left] and/or accepting [clicking the checkmark] it.) – Torbjørn T. Oct 26 '15 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.