LyXInserted coded Table appears in wrong Place

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
ArcanaNoir
Posts: 2
Joined: Mon Sep 02, 2013 7:57 pm

Inserted coded Table appears in wrong Place

Post by ArcanaNoir »

I am trying to include a "Cayley Table" or multiplication table in my LyX document. I did not know how to do that using the built-in LyX features, if someone can explain it that would be a solution. However, since I did not know how to make LyX do it, I inserted the Latex code instead. The table looks fine, but it does not appear where I want it to be. I put the code after the sentence where I want it, but it appears much later in the paragraph. I have actually three tables, and they all are appearing together in the same place, some random location in the paragraph. I tried making new paragraphs around the latex code, but this did not help. How can I get the tables to show up in the right places in my paragraph? Also, how can I center them? I have attached a picture of one of the tables in case someone knows how to make LyX produce the table.

I don't know if it will help given the LyX environment, but here is what my code looks like (the table code is in a red LaTeX box).

Code: Select all

... This completes the first table.

\begin{table}
  \begin{tabular}{c|cccc}
    $\cdot$ & 1 & a & b & c \\ \hline
          1 & 1 & a & b & c \\
          a & a & c & 1 & b \\
          b & b & 1 & c & a \\
          c & c & b & a & 1
  \end{tabular}
\end{table}

For the next table we make ...
Attachments
cayleytable.png
cayleytable.png (2.52 KiB) Viewed 23282 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

GerlofVito
Posts: 27
Joined: Wed May 16, 2012 8:24 pm

Inserted coded Table appears in wrong Place

Post by GerlofVito »

Here is an update to your code which should solve both your issues:

Code: Select all

\begin{table}[h!]
\centering
  \begin{tabular}{c|cccc}
    $\cdot$ & 1 & a & b & c \\ \hline
          1 & 1 & a & b & c \\
          a & a & c & 1 & b \\
          b & b & 1 & c & a \\
          c & c & b & a & 1
  \end{tabular}
\end{table}
Re: Table placement. The \begin{table} macro creates a 'float' which encompasses everything until the \end{table} macro. LaTeX tries to find an optimal place for each float using its own algorithms unless you tell it to do something else. The [h!] option tells LaTeX to put the table float right where it appears in your document.

You can accomplish the same thing in LyX by right clicking the gray box that says "float: Table" and selecting 'Settings ...' Then, unclick 'use default placement' and select 'Here definitely' instead.

Re: Centering. Put the \centering command inside the table float environment, and everything inside will be center-aligned.

You can accomplish the same thing in LyX by putting your cursor directly to the left of the table and right clicking. Select 'Paragraph Settings' from the pop-up menu and then choose 'Center' under 'Alignment'.
ArcanaNoir
Posts: 2
Joined: Mon Sep 02, 2013 7:57 pm

Re: Inserted coded Table appears in wrong Place

Post by ArcanaNoir »

Thanks!
Post Reply