Latex: flushleft environment within tabular cells

  • LaTeX
  • Thread starter lavster
  • Start date
  • Tags
    Latex
In summary, there is an error in the given code, specifically in using the flushleft environment within the tabular cells and the equation environment within the tabular cells. It is recommended to use the raggedright environment instead of flushleft and to use the centering command instead of the center environment. It is also suggested to use more table placement options, to avoid using strange fixes such as \mbox commands, to use the booktabs package for better table design, and to be cautious about using multiple labels within a table environment.
  • #1
lavster
217
0
Can anyone tell me what is wrong with what I've written here - its coming up with lots of errors (inlcuded below). I have the \usepackage{multirow} at the beginning. Thanks

[tex]
\begin{table}[h]
\caption{Investigation of interleaf leakage using ion chamber}
\begin{center}
\begin{tabular}{c c c c}

\hline\hline
MLC open/closed & Position from Original (mm) & Reading (per 200MU) & $\mbox{~~}$ Average $\mbox{~~}$ \\ [0.5ex]
\hline\hline
open & 0 & 4.27, 4.26 & $\mbox{~~}$ 4.265 \\
closed & 0 & 0.49 &
\begin{flushleft}
$$\mbox{~~}$$\ldelim \} {3} {7mm} \multirow{3}{*}{0.0493}
\end{flushleft}
\\

closed & 1 & 0.50 & \\
closed & 2 & 0.49 & \\ [1ex]
\hline
\end{tabular}
\label{rubbish}
\end{center}
\caption{Uncertainty of the Measurement}
\begin{center}
\begin{tabular}{c c}

\hline\hline
Source of uncertainty & Uncertainty \\ [0.5ex]
\hline\hline
standard deviation & see equation \ref{SD} \\
scale reading & $\pm$0.01mm \\
response of electrometer & $\pm$0.5\% \\
reproducibility of unit & $\pm$1\% \\

\hline
& \\
where, & \\
\multicolumn{2}{c}{
\begin{equation}
\mbox{~~~~~~~~~~~~~~~~~~~~~~~~~~~}StandardDeviation = \sqrt{\frac{\sum^{n}_{i=0}(x_i-\bar{x})}{n-1}},\mbox{~~~~~~~~~~~~~~~~~~~~~~~~~~~}
\label{SD}
\end{equation}
} \\
& \\
\multicolumn{2}{c}{where $\bar{x}$ is the average value, $x_i$ is the i-th reading and $n$ is the total number of readings.} \\
\end{tabular}
\label{uncert}
\end{center}
\end{table}

[\tex]


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.649 \begin{flushleft}

Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.649 \begin{flushleft}

Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.649 \begin{flushleft}

Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.651 \end{flushleft}

Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.651 \end{flushleft}

Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.651 \end{flushleft}

Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.

! Missing $ inserted.
<inserted text>
$
l.680 }
\\
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

! You can't use `\eqno' in math mode.
\endmathdisplay@a ...\df@tag \@empty \else \veqno
\alt@tag \df@tag \fi \ifx ...
l.680 }
\\
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.

! Missing $ inserted.
<inserted text>
$
l.680 }
\\
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
 
Physics news on Phys.org
  • #2
also how to I insert my text properly?!
 
  • #3
For properly inserting code, use the "Code" button in the post editor.

Regarding the problem: you cannot use a flushleft environment within tabular cells. It's implemented as a list environment, that's why you got the error "Missing \item" because a list consists of items. You could use \http://latex-community.org/know-how/latex/55-latex-general/424-latex-reference-manual#g_t_005craggedright instead.

Also, you cannot use an equation environment within a normal tabular cell. It would work in a paragraph cell, made with the p column specifier, or within \parbox or a minipage environment.

Further tipps:

  • Use more table placement options, such as [!htbp] instead of just [h], to allow more flexible placement. You can find an explanation of these options on LaTeX-Community.org in the post Order of appearance of tables and figures
  • I would not use a center environment within in a table environment, this adds additional vertical space. Instead, I would use \centering. See center vs. \centering for an explanation.
  • \mbox{~~~~~~~~~~~~~~~~~~~~~~~~~~~} and similar are strange fixes - you could use http://latex-community.org/know-how/latex/55-latex-general/424-latex-reference-manual#g_t_005chspace but better would be a proper automatic alignment.
  • Several labels in a table environment could be a problem - perhaps use the subcaption or the subfig package.
  • I strongly recommend to use the booktabs package for nice table design.

Stefan
 

FAQ: Latex: flushleft environment within tabular cells

What is the "Latex multicolumn problem"?

The Latex multicolumn problem refers to an issue that arises when using the multicolumn command in Latex to create a table with multiple columns. It can cause errors or unexpected output in the table.

What causes the "Latex multicolumn problem"?

The Latex multicolumn problem is typically caused by incorrect syntax or mismatched parameters in the multicolumn command. It can also occur when trying to use the command in a situation where it is not supported, such as within a floating environment.

How can I fix the "Latex multicolumn problem"?

To fix the Latex multicolumn problem, you should carefully check the syntax and parameters used in the multicolumn command. Make sure they are correct and match the structure of your table. You may also need to remove any unsupported commands or adjust the placement of the multicolumn command within your code.

Are there any alternative solutions to the "Latex multicolumn problem"?

Yes, there are alternative ways to create tables with multiple columns in Latex. One option is to use the tabularx package, which allows for more flexible and customizable tables. Another option is to use the tabular environment and manually adjust the column widths to achieve the desired layout.

How can I avoid encountering the "Latex multicolumn problem" in the future?

To prevent the Latex multicolumn problem, it is important to carefully read and understand the syntax and parameters of the multicolumn command before using it. Additionally, be aware of any limitations or unsupported situations for the command, and consider using alternative methods for creating tables with multiple columns.

Similar threads

Replies
3
Views
446
Replies
1
Views
3K
Replies
3
Views
874
Replies
2
Views
2K
Back
Top