LaTeX forum ⇒ LyXtable goes out of the margin

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
jije
Posts: 8
Joined: Fri Mar 04, 2016 8:06 pm

table goes out of the margin

Postby jije » Mon Mar 28, 2016 7:40 pm

Image

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
User avatar
Johannes_B
Site Moderator
Posts: 4183
Joined: Thu Nov 01, 2012 4:08 pm

Re: table goes out of the margin

Postby Johannes_B » Mon Mar 28, 2016 10:23 pm

The table is too big.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9845
Joined: Mon Mar 10, 2008 9:44 pm

table goes out of the margin

Postby Stefan Kottwitz » Mon Mar 28, 2016 10:25 pm

Your columns are too wide, that's why the table goes into the margin. Just make them smaller.

However, there are other issues.

  • there should be a (half) space between a value and a unit
  • units should be written upright, not italic: m can be a variable, but 10 m are ten meters.
  • relation signs should be aligned, such as in the coupling constant column
  • the horizontal lines touch the exponents, vertical spacing should be wider
  • double lines should be avoided
  • vertical lines should not be used, horizontal lines maybe for top, header line, bottom

Hard to say how to "click" all this with LyX. Provide the LaTeX export code, and I would show how t make this in LaTeX.

Stefan
LaTeX.org admin

jije
Posts: 8
Joined: Fri Mar 04, 2016 8:06 pm

Re: table goes out of the margin

Postby jije » Mon Mar 28, 2016 10:58 pm

how to make these columns smaller?
and thank you for your help
this is my first document in lyx and I do not know how to use Latex
how to export Latex code?

User avatar
Stefan Kottwitz
Site Admin
Posts: 9845
Joined: Mon Mar 10, 2008 9:44 pm

Re: table goes out of the margin

Postby Stefan Kottwitz » Mon Mar 28, 2016 11:07 pm

There's an "Export to pdfLaTeX" or "Export to LaTeX" item in the first / left top menu of LyX.

Stefan
LaTeX.org admin

jije
Posts: 8
Joined: Fri Mar 04, 2016 8:06 pm

table goes out of the margin

Postby jije » Mon Mar 28, 2016 11:26 pm

%% LyX 2.1.4 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{luainputenc}
\usepackage{array}
\usepackage{float}
\usepackage{amssymb}
 
\makeatletter
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
 
\makeatother
 
\usepackage{babel}
\begin{document}
\begin{table}[H]
\begin{centering}
\begin{tabular}{|>{\centering}p{0.19\textwidth}|>{\centering}p{0.12\textwidth}|>{\centering}p{0.13\textwidth}|c|c|c|}
\hline
Force & Range & Coupling constant & Acts on & Mediator & Theory\tabularnewline
\hline
\hline
Gravity & $\infty$ & $\alpha_{g}\thickapprox10^{-39}$ & All particles & Graviton\footnote{} & Geometrodyanics\tabularnewline
\hline
Weak nuclear  & $<10^{-18}$\ m & $\alpha_{w}\thickapprox10^{-6}$ & Leptons, hadrons & $W^{\pm},Z$ & Flavordyanics\tabularnewline
\hline
Electromagnetism & $\infty$ & $\alpha\thickapprox\frac{1}{137}$ & All charged particles & Photon & Electrodynamics\tabularnewline
\hline
Strong nuclear  & $\thickapprox10^{-15}$ \ m & $\alpha_{g}\thickapprox1$ & Hadrons & Gluon & Chromodynamics\tabularnewline
\hline
\end{tabular}
\par\end{centering}
 
\begin{raggedright}
\begin{minipage}[t]{1\columnwidth}%
$^{1}$only hypothesized, not discovered %
\end{minipage}
\par\end{raggedright}
 
\raggedright{}\caption{Properties of the four fundamental forces\cite{key-3}}
\end{table}
 
\end{document}
Last edited by Stefan Kottwitz on Tue Mar 29, 2016 12:11 am, edited 1 time in total.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9845
Joined: Mon Mar 10, 2008 9:44 pm

table goes out of the margin

Postby Stefan Kottwitz » Tue Mar 29, 2016 12:38 am

A quick shot how I would modify it in LaTeX, to show what I mean with the lines - there are other things that could be improved (I just have to leave for today):

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{luainputenc}
\usepackage{array}
\usepackage{amssymb}
\usepackage{booktabs}% added by Stefan
\usepackage{siunitx}%  added by Stefan
\usepackage{tabularx}% added by Stefan
 
\makeatletter
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
 
\makeatother
 
\usepackage{babel}
\begin{document}
\begin{table}[!htbp]
  {\centering
  \renewcommand{\arraystretch}{1.8}
  \begin{tabularx}{\textwidth}{@{}p{4em}c>{\centering}p{6em}Xc>{\raggedleft}p{5em}@{}}
    \toprule
Force & Range & Coupling constant & Acts on & Mediator & Theory\tabularnewline
    \midrule
Gravity & $\infty$ & $\alpha_{g}\thickapprox10^{-39}$ & All\newline particles & Graviton\footnote{} & Geometro\-dyanics\tabularnewline
Weak nuclear  & $<10^{-18}$\ m & $\alpha_{w}\thickapprox10^{-6}$ & Leptons, hadrons & $W^{\pm},Z$ & Flavor\-dyanics\tabularnewline
Electro\-magnetism & $\infty$ & $\alpha\thickapprox\frac{1}{137}$ & All charged particles & Photon & Electro\-dynamics\tabularnewline
Strong nuclear  & $\thickapprox10^{-15}$ \ m & $\alpha_{g}\thickapprox1$ & Hadrons & Gluon & Chromo\-dynamics\tabularnewline
    \bottomrule
  \end{tabularx}
  \par\smallskip}
  \raggedright
  \begin{minipage}[t]{1\columnwidth}%
    $^{1}$only hypothesized, not discovered %
  \end{minipage}
  \par 
  \caption{Properties of the four fundamental forces\cite{key-3}}
\end{table}
\end{document}


table.png
table.png (34.39 KiB) Viewed 15496 times


Stefan
LaTeX.org admin

scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: table goes out of the margin

Postby scottkosty » Wed Mar 30, 2016 12:34 am

Cross-posted at http://tex.stackexchange.com/questions/ ... age-margin. Please read the following for why it is important to note your other posts: http://latex-community.org/home/latex-c ... crossposts


Return to “LyX”

Who is online

Users browsing this forum: No registered users and 3 guests