LyXtable goes out of the margin

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

table goes out of the margin

Post by jije »

Image

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: table goes out of the margin

Post by Johannes_B »

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: 10308
Joined: Mon Mar 10, 2008 9:44 pm

table goes out of the margin

Post by Stefan Kottwitz »

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

Post by jije »

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: 10308
Joined: Mon Mar 10, 2008 9:44 pm

Re: table goes out of the margin

Post by Stefan Kottwitz »

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

Post by jije »

Code: Select all

%% 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: 10308
Joined: Mon Mar 10, 2008 9:44 pm

table goes out of the margin

Post by Stefan Kottwitz »

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):

Code: Select all

\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 21329 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

Post by scottkosty »

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
Post Reply