Graphics, Figures & Tablesbreak a long table at the same page

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

break a long table at the same page

Post by NELLLY »

Hello, I have a long table with only two columns A and B. Instead of breaking it at successive pages I need to break it at the same page to use the free space. That is I like the table to be of the form:
A B A B A B...
Is there a solution?

Code: Select all

\documentclass{report}
\usepackage{booktabs}
\begin{document}
\setlength{\tabcolsep}{2cm}
\begin{table}
\begin{center}
\caption{Optimal solutions of the basic Bayesian $np$ control chart for infinite horizon length}
\begin{tabular}{cc}\toprule[1.2pt]
A&B\\\midrule[1.2pt]
0-0,005     & 1  \\
0,06:0,07   & 2  \\
0,008:0,009 & 3  \\
0,01        & 4  \\
0,011:0,017 & 1  \\
0,018:0,02  & 2  \\
0,021:0,022 & 3  \\
0,023       & 4  \\
0,024:0,029 & 1  \\
0,03        & 3  \\
0,031:0,033 & 2  \\
0,034:0,035 & 3  \\
0,036:0,042 & 1  \\
0,043:0,046 & 2  \\
0,047       & 3  \\
0,048:0,055 & 1  \\
0,056:0,059 & 2  \\
0,06:0,069  & 1  \\
0,07:0,072  & 2  \\
0,073:0,082 & 1  \\
0,083:0,085 & 2  \\
0,086:0,089 & 1  \\
0,09        & 2  \\
0,091:0,093 & 1  \\
0,094       & 3  \\
0,095:0,096 & 1  \\
0,097:0,099 & 2  \\
0,1:0,103   & 1  \\
0,104:0,105 & 2  \\
0,106:0,108 & 1  \\
0,109       & 3  \\
0,11:0,111  & 1  \\
0,112:0,113 & 2  \\
0,114:0,118 & 1  \\
0,119:0,12  & 2  \\
0,121:0,122 & 1  \\
0,123       & 1  \\
0,124:0,125 & 3  \\
0,126:0,128 & 2  \\
0,129:0,133 & 1  \\
0,134:0,136 & 2  \\
0,137:0,139 & 1  \\
0,14:0,141  & 3  \\
0,142:0,143 & 2  \\
0,144:0,149 & 1  \\
0,15:0,152  & 2  \\
0,153:0,155 & 1  \\
0,156:0,157 & 3  \\
0,158:0,159 & 2  \\
0,160:0,165 & 1  \\
0,166:0,169 & 2  \\
0,17:0,171  & 4  \\
0,173:0,174 & 3  \\
0,175       & 2  \\
0,176:0,182 & 1  \\
0,183:0,187 & 2  \\
0,188:0,189 & 4  \\
0,19:0,191  & 3  \\
0,192       & 2  \\
0,193:0,2   & 1  \\
0,202       & 3  \\
0,203:0,205 & 2  \\
0,206       & 1  \\
0,207:0,208 & 4  \\
0,209       & 3  \\
0,21        & 2  \\
0,211:0,219 & 1  \\
0,222:0,223 & 2  \\
0,224       & 5  \\
0,225       & 6  \\
0,226:0,227 & 4  \\
0,228       & 3  \\
0,229       & 3  \\
0,23        & 2  \\
0,231:0,239 & 1  \\
0,24        & 2  \\
0,241:0,242 & 3  \\
0,243:0,244 & 2  \\
0,245       & 5  \\
0,246       & 6  \\
0,247       & 4  \\
0,248:0,249 & 3  \\
0,251:0,26  & 1  \\
0,273:0,276 & 1  \\
0,277       & 8  \\
0,278       & 7  \\
0,279       & 6  \\
0,28        & 19 \\
0,281       & 1  \\
0,282       & 7  \\
0,283       & 9  \\
0,284       & 21 \\
0,285       & 7  \\
0,286       & 8  \\
0,287       & 6  \\
0,288       & 21 \\
0,289       & 5  \\
0,29        & 19 \\
0,291       & 22 \\
0,292       & 21 \\
0,293       & 19 \\
0,294:0,295 & 22 \\
0,296       & 21 \\
0,297       & 23 \\
0,298       & 20 \\
0,299       & 22 \\
0,3         & 25 \\
0,301       & 24 \\
0,302:0,303 & 22 \\
0,304       & 10 \\
0,305:0,306 & 23 \\
0,307       & 24 \\
0,308:0,309 & 23 \\
0,31        & 22 \\
0,311       & 21 \\
0,312       & 20 \\
0,313       & 26 \\
0,314:0,315 & 22 \\
0,316       & 24 \\
0,317       & 22 \\
0,318       & 26 \\
0,319       & 23 \\
0,32        & 24 \\
0,321       & 26 \\
0,322       & 25 \\
0,323       & 23 \\
0,324       & 21 \\
0,325       & 24 \\
0,326       & 26 \\
0,327       & 25 \\
0,328:0,329 & 24 \\
0,33        & 23 \\
0,331       & 22 \\
0,332       & 28 \\
0,333       & 27 \\
0,334       & 22 \\
0,335       & 27 \\
0,336       & 25 \\
0,337       & 26 \\
0,338       & 22 \\
0,339       & 24 \\
0,34        & 23 \\
0,341       & 25 \\
0,342:0,343 & 24 \\
0,344       & 23 \\
0,345       & 25 \\
0,346:0,347 & 26 \\
0.357       & 26 \\
0.358       & 27 \\
0.359       & 25 \\
0.36        & 25 \\
0.361       & 24 \\
0.362       & 26 \\
0.363       & 25 \\
0.364       & 25 \\
0.365       & 24 \\
0.366       & 26 \\
0.367       & 27 \\
0.368       & 28 \\
0.369       & 25 \\
0.3700      & 28 \\
0.3710      & 26 \\
0.3720      & 25 \\
0.3730      & 24 \\
0.3740      & 26 \\
0.3750      & 29 \\
0.3760      & 26 \\
0.3770      & 29 \\
0.3780      & 25 \\
0.3790      & 27 \\
0.3800      & 26 \\
0.3810      & 25 \\
0.3820      & 29 \\
0.3830      & 27 \\
0.3840      & 29 \\
0.3850      & 28 \\
0.3860      & 26 \\
0.3870      & 28 \\
0.3880      & 27 \\
0.3890      & 26 \\
0.3900      & 28 \\
0.3910      & 25 \\
0.3920      & 24 \\
0.3930      & 30 \\
0.3940      & 26 \\
0.3950      & 29 \\
0.3960      & 27 \\
0.3970      & 30 \\
0.3980      & 25 \\
0.3990      & 30 \\
0.4000      & 26 \\
0.4010      & 28 \\
0.4020      & 27 \\
0.4030      & 26 \\
0.4040      & 30 \\
0.4050      & 29 \\
0.4060      & 30 \\
0.4070      & 29 \\
0.4080      & 27 \\
0.4090      & 29 \\
0.4100      & 28 \\
0.4110      & 29 \\
0.4120      & 29 \\
0.4130      & 26 \\
0.4140      & 29 \\
0.4150      & 28 \\
0.4160      & 27 \\
0.4170      & 29 \\
0.4180      & 28 \\
0.4190      & 28 \\
0.4200      & 26 \\
0.4210      & 31 \\
0.4220      & 27 \\
0.4230      & 26 \\
0.4240      & 28 \\
0.4250      & 31 \\
0.4260      & 28 \\
0.4270      & 31 \\
0.4280      & 30 \\
0.4290      & 28 \\
0.4300      & 30 \\
0.4310      & 27 \\
0.4320      & 29 \\
0.4330      & 30 \\
0.4340      & 31 \\
0.4350      & 30 \\
0.4360      & 29 \\
0.4370      & 29 \\
0.4380      & 32 \\
0.4390      & 30 \\
0.4400      & 31 \\
0.4410      & 29 \\
0.4420      & 32 \\
0.4430      & 27 \\
0.4440      & 43 \\
0.4450      & 28 \\
0.4460      & 30 \\
0.4470      & 31 \\
0.4480      & 28 \\
0.4490      & 32 \\
0,45:1      & 1  \\\bottomrule[1.2pt]
\end{tabular}
\end{center}
\end{table}
\end{document}
Thanks.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

break a long table at the same page

Post by Johannes_B »

Unfortunately not, you have to split the large tabular into two seprate tabulars (or three or four).
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

break a long table at the same page

Post by NELLLY »

Hi,
By searching on the web, I adopted the following solution for whom interested:

Code: Select all

\documentclass{report}
\usepackage{booktabs}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{filecontents}
\begin{document}

\begin{filecontents*}{t_13.dat}
A B
0-0,005	1
0,06:0,07	2
0,008:0,009	3
0,01	4
0,011:0,017	1
0,018:0,02	2
0,021:0,022	3
0,023	4
0,024:0,029	1
0,03	3
0,031:0,033	2
0,034:0,035	3
0,036:0,042	1
0,043:0,046	2
0,047	3
0,048:0,055	1
0,056:0,059	2
0,06:0,069	1
0,07:0,072	2
0,073:0,082	1
0,083:0,085	2
0,086:0,089	1
0,09	2
0,091:0,093	1
0,094	3
0,095:0,096	1
0,097:0,099	2
0,1:0,103	1
0,104:0,105	2
0,106:0,108	1
0,109	3
0,11:0,111	1
0,112:0,113	2
0,114:0,118	1
0,119:0,12	2
0,121:0,122	1
0,123	1
0,124:0,125	3
0,126:0,128	2
0,129:0,133	1
0,134:0,136	2
0,137:0,139	1
0,14:0,141	3
0,142:0,143	2
0,144:0,149	1
0,15:0,152	2
0,153:0,155	1
0,156:0,157	3
0,158:0,159	2
0,160:0,165	1
0,166:0,169	2
0,17:0,171	4
0,173:0,174	3
0,175	2
0,176:0,182	1
0,183:0,187	2
0,188:0,189	4
0,19:0,191	3
0,192	2
0,193:0,2	1
0,202	3
0,203:0,205	2
0,206	1
0,207:0,208	4
0,209	3
0,21	2
0,211:0,219	1
0,222:0,223	2
0,224	5
0,225	6
0,226:0,227	4
0,228	3
0,229	3
0,23	2
0,231:0,239	1
0,24	2
0,241:0,242	3
0,243:0,244	2
0,245	5
0,246	6
0,247	4
0,248:0,249	3
0,251:0,26	1
0,273:0,276	1
0,277	8
0,278	7
0,279	6
0,28	19
0,281	1
0,282	7
0,283	9
0,284	21
0,285	7
0,286	8
0,287	6
0,288	21
0,289	5
0,29	19
0,291	22
0,292	21
0,293	19
0,294:0,295	22
0,296	21
0,297	23
0,298	20
0,299	22
0,3	25
0,301	24
0,302:0,303	22
0,304	10
0,305:0,306	23
0,307	24
0,308:0,309	23
0,31	22
0,311	21
0,312	20
0,313	26
0,314:0,315	22
0,316	24
0,317	22
0,318	26
0,319	23
0,32	24
0,321	26
0,322	25
0,323	23
0,324	21
0,325	24
0,326	26
0,327	25
0,328:0,329	24
0,33	23
0,331	22
0,332	28
0,333	27
0,334	22
0,335	27
0,336	25
0,337	26
0,338	22
0,339	24
0,34	23
0,341	25
0,342:0,343	24
0,344	23
0,345	25
0,346:0,347	26
0.357	26
0.358	27
0.359	25
0.36	25
0.361	24
0.362	26
0.363	25
0.364	25
0.365	24
0.366	26
0.367	27
0.368	28
0.369	25
0.3700	28
0.3710	26
0.3720	25
0.3730	24
0.3740	26
0.3750	29
0.3760	26
0.3770	29
0.3780	25
0.3790	27
0.3800	26
0.3810	25
0.3820	29
0.3830	27
0.3840	29
0.3850	28
0.3860	26
0.3870	28
0.3880	27
0.3890	26
0.3900	28
0.3910	25
0.3920	24
0.3930	30
0.3940	26
0.3950	29
0.3960	27
0.3970	30
0.3980	25
0.3990	30
0.4000	26
0.4010	28
0.4020	27
0.4030	26
0.4040	30
0.4050	29
0.4060	30
0.4070	29
0.4080	27
0.4090	29
0.4100	28
0.4110	29
0.4120	29
0.4130	26
0.4140	29
0.4150	28
0.4160	27
0.4170	29
0.4180	28
0.4190	28
0.4200	26
0.4210	31
0.4220	27
0.4230	26
0.4240	28
0.4250	31
0.4260	28
0.4270	31
0.4280	30
0.4290	28
0.4300	30
0.4310	27
0.4320	29
0.4330	30
0.4340	31
0.4350	30
0.4360	29
0.4370	29
0.4380	32
0.4390	30
0.4400	31
0.4410	29
0.4420	32
0.4430	27
0.4440	43
0.4450	28
0.4460	30
0.4470	31
0.4480	28
0.4490	32
0,45:1	1
\end{filecontents*}
\pgfplotstableset{
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule}}
%\pgfplotstabletypeset[string type]{pgfplotstable.example2.dat}%
%
\clearpage
\begin{table}
\caption{Optimal sample size values for the different values of $p$ for stage $t=13$}
\begin{scriptsize}
\pgfplotstabletypeset[
columns={A,B,A,B,A,B,A,B,A,B,A,B},
display columns/0/.style={select equal part entry of={0}{6},string type},% first part of ‘A’
display columns/1/.style={select equal part entry of={0}{6},string type},% first part of ‘B’
display columns/2/.style={select equal part entry of={1}{6},string type},% second part of ‘A’
display columns/3/.style={select equal part entry of={1}{6},string type},% second part of ‘B’
display columns/4/.style={select equal part entry of={2}{6},string type},% third part of ‘A’
display columns/5/.style={select equal part entry of={2}{6},string type},% third part of ‘B’
display columns/6/.style={select equal part entry of={3}{6},string type},% third part of ‘A’
display columns/7/.style={select equal part entry of={3}{6},string type},% third part of ‘B’
display columns/8/.style={select equal part entry of={4}{6},string type},% third part of ‘A’
display columns/9/.style={select equal part entry of={4}{6},string type},% third part of ‘B’
display columns/10/.style={select equal part entry of={5}{6},string type},% third part of ‘A’
display columns/11/.style={select equal part entry of={5}{6},string type},% third part of ‘B’
]{t_13.dat}
\end{scriptsize}
\end{table}
\end{document}
Post Reply