我该如何修改代码,让图表直接显示在同一页的表格下方?另外,我想确保图表仅出现在第 1 部分...在我进行的其他一些“运行”中,图表被“发送”到第 2 部分(而不是保留在第 1 部分)
\documentclass[11,fleqn]{article}
\usepackage{verbatim}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{amstext}
\usepackage{mathtools}
\usepackage{hyperref,parskip}
\usepackage{booktabs,multicol,multirow,tabularx}
\usepackage{longtable}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\title{TEST}
\begin{document}
\noindent
\maketitle
\section{Introduction}
% Table generated by Excel2LaTeX from sheet 'latek'
\begin{table}[htbp]
\centering
\caption{Table1}
\begin{tabular} {ccccccccccc}
\multicolumn{1}{c}{hour} & P\_c & P\_f & Q\_h & P\_h & L\_h & test1 & test2 & test3 & test4 & \multicolumn{1}{c}{test6} \\
\multicolumn{1}{c}{0} & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & \multicolumn{1}{c}{10} \\
\midrule
1 & \$ 120 & \$ 100 & 100 & \$ 10 & 10 & \$ 1,200 & \$ 100 & \$ 1,100 & \$ (9,000) & \$ (7,900) \\
2 & \$ 120 & \$ 100 & 100 & \$ 20 & 20 & \$ 2,400 & \$ 400 & \$ 2,000 & \$ (8,000) & \$ (6,000) \\
3 & \$ 120 & \$ 100 & 100 & \$ 30 & 30 & \$ 3,600 & \$ 900 & \$ 2,700 & \$ (7,000) & \$ (4,300) \\
4 & \$ 120 & \$ 100 & 100 & \$ 40 & 40 & \$ 4,800 & \$ 1,600 & \$ 3,200 & \$ (6,000) & \$ (2,800) \\
5 & \$ 120 & \$ 100 & 100 & \$ 50 & 50 & \$ 6,000 & \$ 2,500 & \$ 3,500 & \$ (5,000) & \$ (1,500) \\
6 & \$ 120 & \$ 100 & 100 & \$ 60 & 60 & \$ 7,200 & \$ 3,600 & \$ 3,600 & \$ (4,000) & \$ (400) \\
7 & \$ 120 & \$ 100 & 100 & \$ 70 & 70 & \$ 8,400 & \$ 4,900 & \$ 3,500 & \$ (3,000) & \$ 500 \\
8 & \$ 120 & \$ 100 & 100 & \$ 80 & 80 & \$ 9,600 & \$ 6,400 & \$ 3,200 & \$ (2,000) & \$ 1,200 \\
9 & \$ 120 & \$ 100 & 100 & \$ 90 & 90 & \$ 10,800 & \$ 8,100 & \$ 2,700 & \$ (1,000) & \$ 1,700 \\
10 & \$ 120 & \$ 100 & 100 & \$ 100 & 100 & \$ 12,000 & \$ 10,000 & \$ 2,000 & \$ - & \$ 2,000 \\
11 & \$ 120 & \$ 100 & 100 & \$ 110 & 110 & \$ 13,200 & \$ 12,100 & \$ 1,100 & \$ 1,000 & \$ 2,100 \\
12 & \$ 120 & \$ 100 & 100 & \$ 120 & 120 & \$ 14,400 & \$ 14,400 & \$ - & \$ 2,000 & \$ 2,000 \\
13 & \$ 120 & \$ 100 & 100 & \$ 130 & 130 & \$ 15,600 & \$ 16,900 & \$ (1,300) & \$ 3,000 & \$ 1,700 \\
14 & \$ 120 & \$ 100 & 100 & \$ 140 & 140 & \$ 16,800 & \$ 19,600 & \$ (2,800) & \$ 4,000 & \$ 1,200 \\
15 & \$ 120 & \$ 100 & 100 & \$ 150 & 150 & \$ 18,000 & \$ 22,500 & \$ (4,500) & \$ 5,000 & \$ 500 \\
16 & \$ 120 & \$ 100 & 100 & \$ 160 & 160 & \$ 19,200 & \$ 25,600 & \$ (6,400) & \$ 6,000 & \$ (400) \\
17 & \$ 120 & \$ 100 & 100 & \$ 170 & 170 & \$ 20,400 & \$ 28,900 & \$ (8,500) & \$ 7,000 & \$ (1,500) \\
18 & \$ 120 & \$ 100 & 100 & \$ 180 & 180 & \$ 21,600 & \$ 32,400 & \$ (10,800) & \$ 8,000 & \$ (2,800) \\
19 & \$ 120 & \$ 100 & 100 & \$ 190 & 190 & \$ 22,800 & \$ 36,100 & \$ (13,300) & \$ 9,000 & \$ (4,300) \\
20 & \$ 120 & \$ 100 & 100 & \$ 200 & 200 & \$ 24,000 & \$ 40,000 & \$ (16,000) & \$ 10,000 & \$ (6,000) \\
21 & \$ 120 & \$ 100 & 100 & \$ 210 & 210 & \$ 25,200 & \$ 44,100 & \$ (18,900) & \$ 11,000 & \$ (7,900) \\
22 & \$ 120 & \$ 100 & 100 & \$ 220 & 220 & \$ 26,400 & \$ 48,400 & \$ (22,000) & \$ 12,000 & \$ (10,000) \\
23 & \$ 120 & \$ 100 & 100 & \$ 230 & 230 & \$ 27,600 & \$ 52,900 & \$ (25,300) & \$ 13,000 & \$ (12,300) \\
24 & \$ 120 & \$ 100 & 100 & \$ 240 & 240 & \$ 28,800 & \$ 57,600 & \$ (28,800) & \$ 14,000 & \$ (14,800) \\
\cmidrule{2-11} \end{tabular}%
\label{tab:addlabel}%
\end{table}%
\begin{figure}
\centering
\caption{test}
\pgfplotstableread{
hour test test test
1 1100 -9000 -7900
2 2000 -8000 -6000
3 2700 -7000 -4300
4 3200 -6000 -2800
5 3500 -5000 -1500
6 3600 -4000 -400
7 3500 -3000 500
8 3200 -2000 1200
9 2700 -1000 1700
10 2000 0 2000
11 1100 1000 2100
12 0 2000 2000
13 -1300 3000 1700
14 -2800 4000 1200
15 -4500 5000 500
16 -6400 6000 -400
17 -8500 7000 -1500
18 -10800 8000 -2800
19 -13300 9000 -4300
20 -16000 10000 -6000
21 -18900 11000 -7900
22 -22000 12000 -10000
23 -25300 13000 -12300
24 -28800 14000 -14800
}\mytable
\begin{tikzpicture} [scale=0.75]
\begin{axis}
[
axis lines=middle,
scaled ticks=false,
xlabel=hour,
yticklabel={{\$\pgfmathprintnumber{\tick}}}
]
\addplot table [x index=0, y index=1,mark=none]{\mytable} node[right,pos=0.50] (endofplotsquare) {test};
\addplot table [x index=0, y index=2,mark=none]{\mytable} node[above,pos=0.75] at (endofplotsquare){test};
\addplot table [x index=0, y index=3,mark=none,color=green]{\mytable} node[above,pos=0.75] at (endofplotsquare){test};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
答案1
这是只是如果页面上没有其他内容(特别是没有论文标题和分段命令),那么将两个浮点数放在一页上是可行的。
您还应努力减少表格材料的宽度。例如,删除这 192\$
条指令并将 的值减少\tabcolsep
25%(从6pt
到4.5pt
)。
\documentclass[11,fleqn]{article}
\usepackage[skip=0.5\baselineskip]{caption}
\usepackage{booktabs}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{table}[t!]
\setlength\tabcolsep{4.5pt}
\centering
\caption{Table1} \label{tab:addlabel}
\begin{tabular} {@{} *{11}{r} @{}}
\toprule
hour & P\_c & P\_f & Q\_h & P\_h & L\_h & test1 & test2 & test3 & test4 & test6 \\
0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\
\midrule
1 & 120 & 100 & 100 & 10 & 10 & 1,200 & 100 & 1,100 & (9,000) & (7,900) \\
2 & 120 & 100 & 100 & 20 & 20 & 2,400 & 400 & 2,000 & (8,000) & (6,000) \\
3 & 120 & 100 & 100 & 30 & 30 & 3,600 & 900 & 2,700 & (7,000) & (4,300) \\
4 & 120 & 100 & 100 & 40 & 40 & 4,800 & 1,600 & 3,200 & (6,000) & (2,800) \\
5 & 120 & 100 & 100 & 50 & 50 & 6,000 & 2,500 & 3,500 & (5,000) & (1,500) \\
6 & 120 & 100 & 100 & 60 & 60 & 7,200 & 3,600 & 3,600 & (4,000) & (400) \\
7 & 120 & 100 & 100 & 70 & 70 & 8,400 & 4,900 & 3,500 & (3,000) & 500 \\
8 & 120 & 100 & 100 & 80 & 80 & 9,600 & 6,400 & 3,200 & (2,000) & 1,200 \\
9 & 120 & 100 & 100 & 90 & 90 & 10,800 & 8,100 & 2,700 & (1,000) & 1,700 \\
10 & 120 & 100 & 100 & 100 & 100 & 12,000 & 10,000 & 2,000 & - & 2,000 \\
11 & 120 & 100 & 100 & 110 & 110 & 13,200 & 12,100 & 1,100 & 1,000 & 2,100 \\
12 & 120 & 100 & 100 & 120 & 120 & 14,400 & 14,400 & - & 2,000 & 2,000 \\
13 & 120 & 100 & 100 & 130 & 130 & 15,600 & 16,900 & (1,300) & 3,000 & 1,700 \\
14 & 120 & 100 & 100 & 140 & 140 & 16,800 & 19,600 & (2,800) & 4,000 & 1,200 \\
15 & 120 & 100 & 100 & 150 & 150 & 18,000 & 22,500 & (4,500) & 5,000 & 500 \\
16 & 120 & 100 & 100 & 160 & 160 & 19,200 & 25,600 & (6,400) & 6,000 & (400) \\
17 & 120 & 100 & 100 & 170 & 170 & 20,400 & 28,900 & (8,500) & 7,000 & (1,500) \\
18 & 120 & 100 & 100 & 180 & 180 & 21,600 & 32,400 & (10,800) & 8,000 & (2,800) \\
19 & 120 & 100 & 100 & 190 & 190 & 22,800 & 36,100 & (13,300) & 9,000 & (4,300) \\
20 & 120 & 100 & 100 & 200 & 200 & 24,000 & 40,000 & (16,000) & 10,000 & (6,000) \\
21 & 120 & 100 & 100 & 210 & 210 & 25,200 & 44,100 & (18,900) & 11,000 & (7,900) \\
22 & 120 & 100 & 100 & 220 & 220 & 26,400 & 48,400 & (22,000) & 12,000 & (10,000) \\
23 & 120 & 100 & 100 & 230 & 230 & 27,600 & 52,900 & (25,300) & 13,000 & (12,300) \\
24 & 120 & 100 & 100 & 240 & 240 & 28,800 & 57,600 & (28,800) & 14,000 & (14,800) \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[h!]
\centering
\caption{test}
\pgfplotstableread{
hour test test test
1 1100 -9000 -7900
2 2000 -8000 -6000
3 2700 -7000 -4300
4 3200 -6000 -2800
5 3500 -5000 -1500
6 3600 -4000 -400
7 3500 -3000 500
8 3200 -2000 1200
9 2700 -1000 1700
10 2000 0 2000
11 1100 1000 2100
12 0 2000 2000
13 -1300 3000 1700
14 -2800 4000 1200
15 -4500 5000 500
16 -6400 6000 -400
17 -8500 7000 -1500
18 -10800 8000 -2800
19 -13300 9000 -4300
20 -16000 10000 -6000
21 -18900 11000 -7900
22 -22000 12000 -10000
23 -25300 13000 -12300
24 -28800 14000 -14800
}\mytable
\begin{tikzpicture} [scale=0.75]
\begin{axis}
[
axis lines=middle,
scaled ticks=false,
xlabel=hour,
yticklabel={{\$\pgfmathprintnumber{\tick}}}
]
\addplot table [x index=0, y index=1,mark=none]{\mytable} node[right,pos=0.50] (endofplotsquare) {test};
\addplot table [x index=0, y index=2,mark=none]{\mytable} node[above,pos=0.75] at (endofplotsquare){test};
\addplot table [x index=0, y index=3,mark=none,color=green]{\mytable} node[above,pos=0.75] at (endofplotsquare){test};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}