## LaTeX forum ⇒ TeXworks ⇒ how to format better when we have tables

Information and discussion about TeXworks, an integrated LaTeX environment for several platforms
yaozhao
Posts: 57
Joined: Sat Oct 27, 2018 10:38 pm

### how to format better when we have tables

\subsection{Q11}
Imagine that the interest rate on your savings account was 1\% per year and inflation was 2\%per year. After 1 year, how much would you be able to buy with the money in this account?

\begin{table}
\centering
\caption{Q11}
\scalebox{0.7}{
{
\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}
\begin{tabular}{l*{1}{cc}}
\hline\hline
&\multicolumn{2}{c}{q11}  \\
&           b&         pct\\
\hline
Don't know&	122&	 	14\\
Total       &         841&         100\\
\hline
$$N$$       &         841&            \\
\hline\hline
\end{tabular}
}
}
\label{T2}
\end{table}

\subsection{Q12}
If interest rates rise, what will typically happen to bond prices?

\begin{table}
\centering
\caption{Q12}
\scalebox{0.7}{
{
\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}
\begin{tabular}{l*{1}{cc}}
\hline\hline
&\multicolumn{2}{c}{q12}  \\
&           b&         pct\\
\hline
Don't know&	305&	 	36\\
Total       &         841&         100\\
\hline
$$N$$       &         841&            \\
\hline\hline
\end{tabular}
}
}
\label{T2}
\end{table}

I want to each table below its corresponding section. In other words, each subsection has one table below. Then a new subsection, its table, a new subsection, its table......

LaTeXguide.org • LaTeX-Cookbook.net

Stefan Kottwitz
Posts: 9880
Joined: Mon Mar 10, 2008 9:44 pm

### how to format better when we have tables

You can load the placeins package:

\usepackage{placeins}

Then, use the command \FloatBarrier before a subsection so no table can float beyond the next subsection heading.

If you really want to fix table positions, then, instead of above, add

\usepackage{float}

and use the [H] option, such as

\begin{table}[H]

Stefan