Graphics, Figures & TablesTable = 1 problem

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
exactos
Posts: 8
Joined: Sat Jul 24, 2010 10:47 pm

Table = 1 problem

Post by exactos »

Code: Select all

\documentclass[11pt]{article}
\usepackage{graphicx,latexsym,amsfonts,amssymb,amsmath,verbatim,theapa,lscape,multirow,xcolor}


\begin{document}

    \begin{table}[]
    \caption{\textbf{Table }Estimates of the Linear Mixed Effects Model
    of Treatment Effects for the Buyer Prices}
    \vspace{2pt}

        \begin{tabular}{p{82pt}p{31pt}p{37pt}p{85pt}p{19pt}p{44pt}p{42pt}}
        \hline \multicolumn{7}{c} {\textit{{{\footnotesize Price$_{ij}$ -
        P$^{t}$=\begin{math}\mathrm{\mu}\end{math}+e$_{i}$+\begin{math}\beta{}\end{math}$_{1}$OCM$_{i}$+\begin{math}\beta{}\end{math}$_{2}$PCM$_{i}$+\begin{math}\beta{}\end{math}$_{3}$First$_{i}$
        +
        \begin{math}\beta{}\end{math}$_{4}$Second$_{i}$+\begin{math}\beta{}\end{math}$_{5}$OCM$_{i}$\begin{math}\times{}\end{math}First$_{i}$+\begin{math}\beta{}\end{math}$_{6}$OCM$_{i}$\begin{math}\times{}\end{math}Second$_{i}$+
        \begin{math}\beta{}\end{math}$_{7}$PCM$_{i}$\begin{math}\times{}\end{math}First$_{i}$+\begin{math}\beta{}\end{math}$_{8}$PCM$_{i}$\begin{math}\times{}\end{math}Second$_{i}$
        + \begin{math}\epsilon{}\end{math}$_{ij}$,  e$_{i}$
        \textasciitilde{} N(0,\begin{math}\sigma{}\end{math}$^{2}$$_{1}$)
        and
        \begin{math}\epsilon{}\end{math}$_{ij}$ \textasciitilde{}
        N(0,\begin{math}\sigma{}\end{math}$^{2}$$_{2,i}$)}} }} \\
            \hline
            &
            {\footnotesize Estimate}
            &
            {\footnotesize Std. Error}
            &
            {\footnotesize Degrees \!of \!Freedom}
            &
            {\footnotesize H$_{a}$}
            &
            {\footnotesize t-statistic}
            &
            {\footnotesize p-value}
            \\
            \hline

            \textit{{\footnotesize Off-peak}}
            &

            &

            &

            &

            &

            &

            \\

            \textbf{{\footnotesize \begin{math}\mathrm{\mu}\end{math}}}
            &
            \textbf{{\footnotesize -1.21}}
            &
            \textbf{{\footnotesize 5.41}}
            &
            \textbf{{\footnotesize 618}}
            &
            \textbf{{\footnotesize
            \begin{math}\mathrm{\mu}\end{math}\begin{math}>\end{math}0}}
            &
            \textbf{{\footnotesize -0.22}}
            &
            \textbf{{\footnotesize 0.8227}}
            \\

            \\

            \hline

            \\
            \multicolumn{7}{l} { {\footnotesize \textit{Note.} The linear
            mixed-effects model is fit by maximum likelihood with 636 original
            observations and 12 sessions. For purposes of the brevity the
            session random effects are not included in the table.}
            } \\
            \hline
            \end{tabular}
    \end{table}
    \vspace{2pt}


\end{document}
I am trying to construct a big onepage table, without using the tabularx and longtable packages. However, much of the table lies outside the page. Please help me fix the header and footer of the table in plain view.

Thanks in advance.
Last edited by exactos on Thu Jul 29, 2010 8:42 pm, edited 1 time in total.

Recommended reading 2024:

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

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

yago
Posts: 29
Joined: Sat Dec 13, 2008 6:40 pm

Re: Table = 1 problem

Post by yago »

I'm foolish with your table head formula. Can you send us a hand type example of this?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Table = 1 problem

Post by Stefan Kottwitz »

Specify the width of the multicolumn entries, otherwise they'll get too wide, for instance:

Code: Select all

\begin{tabular}{p{82pt}p{31pt}p{37pt}p{85pt}p{19pt}p{44pt}p{42pt}}
            \hline \multicolumn{7}{p{.9\textwidth}}...
...
\multicolumn{7}{p{.9\textwidth}} { {\footnotesize \textit{Note.} The...
Stefan
LaTeX.org admin
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Table = 1 problem

Post by torbjorn t. »

A few points:
  •  
  • Why have you mixed \begin{math}...\end{math} and $...$ so much in the first row? They are, if I'm not mistaken, equivalent. Is there a particular reason why you have used so many math environments? You obviously mean for the text to be set in italic anyway.
  • Is the tildes in the last lines supposed to be mean "roughly similar", or something like that? If so, use \sim in mathmode.
  • You can use the \footnotesize switch just once, within the table environment, in stead of once for each element in the table.
  • \mathrm{\mu} will not give you an upright µ, if that was what you were after. Load the upgreek package, and use \upmu.
  • The \textbf command won't make "µ > 0" bold. Try the \boldsymbol{..} command.
  • Didn't you ask how to remove "Table 1:" from the caption earlier? If so, take at look at the caption package, perhaps that can help.

Now, I don't know if this is correct (with regards to my first two points), so you may have to change it. The table is still to wide for the page, but you had perhaps intended it to be on a landscape page?

I've also added the booktabs package, to get a better looking table. (It provides \toprule/\midrule/\bottomrule.)

Code: Select all

\documentclass[11pt]{article}
\usepackage{amsfonts,amssymb,amsmath,booktabs,upgreek}


\begin{document}
    \begin{table}[h]
    \caption{Estimates of the Linear Mixed Effects Model
    of Treatment Effects for the Buyer Prices}
    \vspace{2pt}
    \footnotesize
        \begin{tabular}{p{82pt}p{31pt}p{37pt}p{85pt}p{19pt}p{44pt}p{42pt}}
        \toprule
        \multicolumn{7}{p{.9\textwidth}} {$ Price_{ij} -
        P^{t}=\upmu+e_{i}+\beta{}_{1}OCM_{i}+\beta{}_{2}PCM_{i}+\beta{}_{3}First_{i}
        +
        \beta{}_{4}Second_{i}+\beta{}_{5}OCM_{i}\times{}First_{i}+\beta{}_{6}OCM_{i}\times{}Second_{i}+
        \beta{}_{7}PCM_{i}\times{}First_{i}+\beta{}_{8}PCM_{i}\times{}Second_{i}
        + \epsilon{}_{ij}$,  \newline
        $e_{i} \sim N(0,\sigma{}^{2}_{1})$
        and 
        $\epsilon{}_{ij} \sim N(0,\sigma{}^{2}_{2,i})$}  \\
            \midrule
            &
            Estimate
            &
            Std. Error
            &
            Degrees \!of \!Freedom
            &
            H$_{a}$
            &
            t-statistic
            &
            p-value
            \\
            \midrule

            \textit{Off-peak}
            &

            &

            &

            &

            &

            &

            \\

            $\boldsymbol{\upmu}$
            &
            \textbf{$-1.21$}
            &
            \textbf{5.41}
            &
            \textbf{618}
            &
             $\boldsymbol{\upmu>0}$
            &
            \textbf{$-0.22$}
            &
            \textbf{0.8227}
            \\

            \\

            \midrule

            \\
            \multicolumn{7}{p{.9\textwidth}} { \textit{Note.} The linear
            mixed-effects model is fit by maximum likelihood with 636 original
            observations and 12 sessions. For purposes of the brevity the
            session random effects are not included in the table.}
            \\
            \bottomrule
            \end{tabular}
    \end{table}
\end{document}
exactos
Posts: 8
Joined: Sat Jul 24, 2010 10:47 pm

Table = 1 problem

Post by exactos »

yago wrote:I'm foolish with your table head formula. Can you send us a hand type example of this?
Yes, it is way more complicated than it should be.
torbjorn t. wrote:Why have you mixed \begin{math}...\end{math} and $...$ so much in the first row? They are, if I'm not mistaken, equivalent. Is there a particular reason why you have used so many math environments? You obviously mean for the text to be set in italic anyway.
I thought doing them individually would be better, but seems to be no noticeable difference.
torbjorn t. wrote:Is the tildes in the last lines supposed to be mean "roughly similar", or something like that? If so, use \sim in mathmode.
Yes.
torbjorn t. wrote:but you had perhaps intended it to be on a landscape page?
Yes. All my tables are in landscape mode.

Thanks everyone, especially torbjorn t. :) I didn't think I was going to get a response anytime soon. Now I just have to learn a few new packages, and my "big" table should be fine.
yago
Posts: 29
Joined: Sat Dec 13, 2008 6:40 pm

Table = 1 problem

Post by yago »

You can use this code where I cute your long formula with a gather* environment. For you page layout you should modify the margins in geometry package. See the packages array and booktabs.

Code: Select all

\documentclass[11pt]{article}
\usepackage{graphicx,latexsym,amsfonts,amssymb,amsmath,verbatim,lscape,multirow,xcolor,array,booktabs}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[labelsep=endash,font=small,labelformat=simple,width=15.6cm,labelfont=bf,figurewithin=none,justification=centering]{caption}
\renewcommand{\thetable}{}
\begin{document}
\begin{center}
\renewcommand{\arraystretch}{1.5}
\begin{table}[!h]
\caption{\textbf{Estimates of the Linear Mixed Effects Model of Treatment Effects for the Buyer Prices}}
\vspace*{-5pt}
\footnotesize{
\begin{gather*}
Price_{ij}-P^{t}=\mu+e_{i}+\beta_{1}OCM_{i}+\beta_{2}PCM_{i}+\beta_{3}First_{i}+\beta_{4}Second_{i}+\beta_{5}OCM_{i}\times First_{i}+\\
+\beta_{6}OCM_{i}\times Second_{i}+\beta_{7}PCM_{i}\times First_{i}+\beta_{8}PCM_{i}\times Second_{i}+\epsilon_{ij},\\
e_{i}\,\raisebox{.4em}{\ensuremath{\sim}}\, N\left(0,\sigma_{1}^{2}\right)\quad\textrm{and}\quad\epsilon_{i,j}\,\raisebox{.4em}{\ensuremath{\sim}}\, N\left(0,\sigma_{2,i}^{2}\right)
\end{gather*}}
\centering
\begin{tabular}{m{60pt}m{38pt}m{50pt}m{95pt}m{2pt}m{45pt}m{35pt}}
\toprule
& \textbf{Estimate} & \textbf{Std. Error} & \textbf{Degrees of Freedom} & $\mathbf{H_{a}}$ & \textbf{t-statistic} & \textbf{p-value}\\
\midrule
\multicolumn{1}{c}{$\mathit{Off-peak}\;\mathbf{\mu}$} & \multicolumn{1}{c}{$\mathbf{-1.21}$} & \multicolumn{1}{c}{$\mathbf{5.41}$} & \multicolumn{1}{c}{$\mathbf{618}$} & \multicolumn{1}{c}{$\mathbf{\mu>0}$} & \multicolumn{1}{c}{$\mathbf{-0.22}$} & \multicolumn{1}{c}{$\mathbf{0.8227}$}\\
\toprule
\end{tabular}
\end{table}
\end{center}
\vspace*{-35pt}
\hspace*{1.2cm}
\begin{minipage}{15cm}
\footnotesize{\emph{Note.} The linear mixed-effects model is fit by maximum likelihood with 636 original observations and 12 sessions. For purposes of the brevity the session random effects are not included in the table.}
\end{minipage}
\end{document}
exactos
Posts: 8
Joined: Sat Jul 24, 2010 10:47 pm

Re: Table = 1 problem

Post by exactos »

Thanks yago :)

How do I get this table within the page borders? I have a few more tables which are giving me the same problem.
Post Reply