Pgfplotstableset, longtable and subcaption
up vote
0
down vote
favorite
I am using pgfplotstableset
and longtable
to read data from a file and format it into a table composed of several subtables. I have managed to create the table and to include a caption over it. However, I would also like to include a subcaption over each one of the subtables and I have not been able to do it.
The desired output should look like:
I have created the table above with caption*
. However, I would prefer to use subcaption
to maintain the consistency of my references. Below, I include the minimal code, which I have used to create the table above. I have tried replacing caption*
with subcaption
and I get the following error:
! Package caption Error: subcaption outside float.
Minimal code.
article.tex:
documentclass{article}
usepackage{conf-simple}
begin{document}
includetable{data/minimal-data.dat}{Minimal data}{minimal-data}
end{document}
conf-simple.sty:
ProvidesPackage{conf-simple}
usepackage{subcaption}
usepackage{pgfplotstable}
usepackage{longtable}
usepackage{booktabs}
pgfplotstableset{
begin table=begin{longtable},
create on use/double/.style={create col/expr={thisrowno{1}*2}},
end table=end{longtable},
}
newcommand{includetable}[3]{
noindentbegin{minipage}{textwidth}
pgfplotstabletypeset[
col sep=space,
header=false,
column type=r,
columns={0,1,double}, % display specified columns
columns/0/.style={string type, column name =},
columns/1/.style={column name=small{Value}},
columns/double/.style={column name=small{Double}},
% requires booktabs to place horiz rules
every head row/.style={before row={caption{#2 label{table:#3}} \ caption*{(a) First subtable} \ toprule
multicolumn{3}{|c|}{Numbers} \ midrule}, after row=midrule},
every last row/.style={after row=bottomrule},
every first column/.style={column type/.add={|}{}},
every column/.style={column type/.add={}{|}},
]{#1}
end{minipage}
noindentbegin{minipage}{textwidth}
pgfplotstabletypeset[col sep=space,
header=false,
columns={0,1}, % display specified columns
columns/0/.style={string type,column name=},
columns/1/.style={column name=small{Value}},
% requires booktabs to place horiz rules
every head row/.style={before row={caption*{(b) Second subtable} \ toprule
multicolumn{2}{|c|}{Numbers} \ midrule }, after row=midrule},
every last row/.style={after row=bottomrule},
every first column/.style={column type/.add={|}{}},
every column/.style={column type/.add={}{|}},
]{#1}
end{minipage}
}
end{document}
Minimal data file:
One 1
Two 2
Three 3
As far as I understand, the problem is related to longtable
not accepting subcaptions but I do not know how to build my table in a different way.
I have found related questions like this and this but they do not solve my issue.
longtable pgfplotstable subcaption
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
up vote
0
down vote
favorite
I am using pgfplotstableset
and longtable
to read data from a file and format it into a table composed of several subtables. I have managed to create the table and to include a caption over it. However, I would also like to include a subcaption over each one of the subtables and I have not been able to do it.
The desired output should look like:
I have created the table above with caption*
. However, I would prefer to use subcaption
to maintain the consistency of my references. Below, I include the minimal code, which I have used to create the table above. I have tried replacing caption*
with subcaption
and I get the following error:
! Package caption Error: subcaption outside float.
Minimal code.
article.tex:
documentclass{article}
usepackage{conf-simple}
begin{document}
includetable{data/minimal-data.dat}{Minimal data}{minimal-data}
end{document}
conf-simple.sty:
ProvidesPackage{conf-simple}
usepackage{subcaption}
usepackage{pgfplotstable}
usepackage{longtable}
usepackage{booktabs}
pgfplotstableset{
begin table=begin{longtable},
create on use/double/.style={create col/expr={thisrowno{1}*2}},
end table=end{longtable},
}
newcommand{includetable}[3]{
noindentbegin{minipage}{textwidth}
pgfplotstabletypeset[
col sep=space,
header=false,
column type=r,
columns={0,1,double}, % display specified columns
columns/0/.style={string type, column name =},
columns/1/.style={column name=small{Value}},
columns/double/.style={column name=small{Double}},
% requires booktabs to place horiz rules
every head row/.style={before row={caption{#2 label{table:#3}} \ caption*{(a) First subtable} \ toprule
multicolumn{3}{|c|}{Numbers} \ midrule}, after row=midrule},
every last row/.style={after row=bottomrule},
every first column/.style={column type/.add={|}{}},
every column/.style={column type/.add={}{|}},
]{#1}
end{minipage}
noindentbegin{minipage}{textwidth}
pgfplotstabletypeset[col sep=space,
header=false,
columns={0,1}, % display specified columns
columns/0/.style={string type,column name=},
columns/1/.style={column name=small{Value}},
% requires booktabs to place horiz rules
every head row/.style={before row={caption*{(b) Second subtable} \ toprule
multicolumn{2}{|c|}{Numbers} \ midrule }, after row=midrule},
every last row/.style={after row=bottomrule},
every first column/.style={column type/.add={|}{}},
every column/.style={column type/.add={}{|}},
]{#1}
end{minipage}
}
end{document}
Minimal data file:
One 1
Two 2
Three 3
As far as I understand, the problem is related to longtable
not accepting subcaptions but I do not know how to build my table in a different way.
I have found related questions like this and this but they do not solve my issue.
longtable pgfplotstable subcaption
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
How is it possible thatarticle.tex
has anend{table}
but nobegin{table}
(and does not have anend{document}
)? Please consider cleaning up your code such that others can start playing with it.
– marmot
Sep 4 at 13:34
@marmot I am sorry about the mistake, I have changed it. The rest of the code has been copied directly from the minimal test I ran so there should be no more errors.
– fa__
Sep 4 at 13:53
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using pgfplotstableset
and longtable
to read data from a file and format it into a table composed of several subtables. I have managed to create the table and to include a caption over it. However, I would also like to include a subcaption over each one of the subtables and I have not been able to do it.
The desired output should look like:
I have created the table above with caption*
. However, I would prefer to use subcaption
to maintain the consistency of my references. Below, I include the minimal code, which I have used to create the table above. I have tried replacing caption*
with subcaption
and I get the following error:
! Package caption Error: subcaption outside float.
Minimal code.
article.tex:
documentclass{article}
usepackage{conf-simple}
begin{document}
includetable{data/minimal-data.dat}{Minimal data}{minimal-data}
end{document}
conf-simple.sty:
ProvidesPackage{conf-simple}
usepackage{subcaption}
usepackage{pgfplotstable}
usepackage{longtable}
usepackage{booktabs}
pgfplotstableset{
begin table=begin{longtable},
create on use/double/.style={create col/expr={thisrowno{1}*2}},
end table=end{longtable},
}
newcommand{includetable}[3]{
noindentbegin{minipage}{textwidth}
pgfplotstabletypeset[
col sep=space,
header=false,
column type=r,
columns={0,1,double}, % display specified columns
columns/0/.style={string type, column name =},
columns/1/.style={column name=small{Value}},
columns/double/.style={column name=small{Double}},
% requires booktabs to place horiz rules
every head row/.style={before row={caption{#2 label{table:#3}} \ caption*{(a) First subtable} \ toprule
multicolumn{3}{|c|}{Numbers} \ midrule}, after row=midrule},
every last row/.style={after row=bottomrule},
every first column/.style={column type/.add={|}{}},
every column/.style={column type/.add={}{|}},
]{#1}
end{minipage}
noindentbegin{minipage}{textwidth}
pgfplotstabletypeset[col sep=space,
header=false,
columns={0,1}, % display specified columns
columns/0/.style={string type,column name=},
columns/1/.style={column name=small{Value}},
% requires booktabs to place horiz rules
every head row/.style={before row={caption*{(b) Second subtable} \ toprule
multicolumn{2}{|c|}{Numbers} \ midrule }, after row=midrule},
every last row/.style={after row=bottomrule},
every first column/.style={column type/.add={|}{}},
every column/.style={column type/.add={}{|}},
]{#1}
end{minipage}
}
end{document}
Minimal data file:
One 1
Two 2
Three 3
As far as I understand, the problem is related to longtable
not accepting subcaptions but I do not know how to build my table in a different way.
I have found related questions like this and this but they do not solve my issue.
longtable pgfplotstable subcaption
I am using pgfplotstableset
and longtable
to read data from a file and format it into a table composed of several subtables. I have managed to create the table and to include a caption over it. However, I would also like to include a subcaption over each one of the subtables and I have not been able to do it.
The desired output should look like:
I have created the table above with caption*
. However, I would prefer to use subcaption
to maintain the consistency of my references. Below, I include the minimal code, which I have used to create the table above. I have tried replacing caption*
with subcaption
and I get the following error:
! Package caption Error: subcaption outside float.
Minimal code.
article.tex:
documentclass{article}
usepackage{conf-simple}
begin{document}
includetable{data/minimal-data.dat}{Minimal data}{minimal-data}
end{document}
conf-simple.sty:
ProvidesPackage{conf-simple}
usepackage{subcaption}
usepackage{pgfplotstable}
usepackage{longtable}
usepackage{booktabs}
pgfplotstableset{
begin table=begin{longtable},
create on use/double/.style={create col/expr={thisrowno{1}*2}},
end table=end{longtable},
}
newcommand{includetable}[3]{
noindentbegin{minipage}{textwidth}
pgfplotstabletypeset[
col sep=space,
header=false,
column type=r,
columns={0,1,double}, % display specified columns
columns/0/.style={string type, column name =},
columns/1/.style={column name=small{Value}},
columns/double/.style={column name=small{Double}},
% requires booktabs to place horiz rules
every head row/.style={before row={caption{#2 label{table:#3}} \ caption*{(a) First subtable} \ toprule
multicolumn{3}{|c|}{Numbers} \ midrule}, after row=midrule},
every last row/.style={after row=bottomrule},
every first column/.style={column type/.add={|}{}},
every column/.style={column type/.add={}{|}},
]{#1}
end{minipage}
noindentbegin{minipage}{textwidth}
pgfplotstabletypeset[col sep=space,
header=false,
columns={0,1}, % display specified columns
columns/0/.style={string type,column name=},
columns/1/.style={column name=small{Value}},
% requires booktabs to place horiz rules
every head row/.style={before row={caption*{(b) Second subtable} \ toprule
multicolumn{2}{|c|}{Numbers} \ midrule }, after row=midrule},
every last row/.style={after row=bottomrule},
every first column/.style={column type/.add={|}{}},
every column/.style={column type/.add={}{|}},
]{#1}
end{minipage}
}
end{document}
Minimal data file:
One 1
Two 2
Three 3
As far as I understand, the problem is related to longtable
not accepting subcaptions but I do not know how to build my table in a different way.
I have found related questions like this and this but they do not solve my issue.
longtable pgfplotstable subcaption
longtable pgfplotstable subcaption
edited Sep 4 at 21:19
John Kormylo
43.4k12465
43.4k12465
asked Sep 4 at 10:30
fa__
14
14
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
How is it possible thatarticle.tex
has anend{table}
but nobegin{table}
(and does not have anend{document}
)? Please consider cleaning up your code such that others can start playing with it.
– marmot
Sep 4 at 13:34
@marmot I am sorry about the mistake, I have changed it. The rest of the code has been copied directly from the minimal test I ran so there should be no more errors.
– fa__
Sep 4 at 13:53
add a comment |
How is it possible thatarticle.tex
has anend{table}
but nobegin{table}
(and does not have anend{document}
)? Please consider cleaning up your code such that others can start playing with it.
– marmot
Sep 4 at 13:34
@marmot I am sorry about the mistake, I have changed it. The rest of the code has been copied directly from the minimal test I ran so there should be no more errors.
– fa__
Sep 4 at 13:53
How is it possible that
article.tex
has an end{table}
but no begin{table}
(and does not have an end{document}
)? Please consider cleaning up your code such that others can start playing with it.– marmot
Sep 4 at 13:34
How is it possible that
article.tex
has an end{table}
but no begin{table}
(and does not have an end{document}
)? Please consider cleaning up your code such that others can start playing with it.– marmot
Sep 4 at 13:34
@marmot I am sorry about the mistake, I have changed it. The rest of the code has been copied directly from the minimal test I ran so there should be no more errors.
– fa__
Sep 4 at 13:53
@marmot I am sorry about the mistake, I have changed it. The rest of the code has been copied directly from the minimal test I ran so there should be no more errors.
– fa__
Sep 4 at 13:53
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Only use fixsubtable
inside a minipage or other group.
documentclass{article}
usepackage{subcaption}
usepackage{longtable}
makeatletter
newcommand{fixsubtable}{letcaption=caption@caption
def@captype{table}}
makeatother
begin{document}
begin{longtable}{@{}c@{}}
caption{No Data}
endhead
endfoot
begin{minipage}{textwidth}
fixsubtable
subcaption{First subtable}
centering
rule{0.25textwidth}{0.25textwidth}
end{minipage}\
end{longtable}
end{document}
This does work if I place the caption and subcaption at the beginning of the minipage. However if I try to placesubcaption
in the style before row, as I was doing with the caption I get the error! Missing endgroup inserted.
. Your solution servers me right except for the fact that it increases the blank space between the subcaption and the subtable.
– fa__
Sep 5 at 7:28
I just noticed thebegin table=begin{longtable},
. There is no point in using longtable inside a minipage. If you have a subtable that needs to have pagebreaks, that is a more difficult problem.
– John Kormylo
Sep 5 at 12:46
I am usinglongtable
andpgfplotstableset
to process the data from a file in order to create a table with several subtables. I am using a minipage for every one of the subtables. That is, I need pagebreaks between the subtables, not in them.
– fa__
Sep 5 at 13:29
So stop usingbegin table=begin{longtable},
etc., which is causing every subtable to use longtable (and consequently disables subcaption again).
– John Kormylo
Sep 5 at 13:44
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Only use fixsubtable
inside a minipage or other group.
documentclass{article}
usepackage{subcaption}
usepackage{longtable}
makeatletter
newcommand{fixsubtable}{letcaption=caption@caption
def@captype{table}}
makeatother
begin{document}
begin{longtable}{@{}c@{}}
caption{No Data}
endhead
endfoot
begin{minipage}{textwidth}
fixsubtable
subcaption{First subtable}
centering
rule{0.25textwidth}{0.25textwidth}
end{minipage}\
end{longtable}
end{document}
This does work if I place the caption and subcaption at the beginning of the minipage. However if I try to placesubcaption
in the style before row, as I was doing with the caption I get the error! Missing endgroup inserted.
. Your solution servers me right except for the fact that it increases the blank space between the subcaption and the subtable.
– fa__
Sep 5 at 7:28
I just noticed thebegin table=begin{longtable},
. There is no point in using longtable inside a minipage. If you have a subtable that needs to have pagebreaks, that is a more difficult problem.
– John Kormylo
Sep 5 at 12:46
I am usinglongtable
andpgfplotstableset
to process the data from a file in order to create a table with several subtables. I am using a minipage for every one of the subtables. That is, I need pagebreaks between the subtables, not in them.
– fa__
Sep 5 at 13:29
So stop usingbegin table=begin{longtable},
etc., which is causing every subtable to use longtable (and consequently disables subcaption again).
– John Kormylo
Sep 5 at 13:44
add a comment |
up vote
0
down vote
Only use fixsubtable
inside a minipage or other group.
documentclass{article}
usepackage{subcaption}
usepackage{longtable}
makeatletter
newcommand{fixsubtable}{letcaption=caption@caption
def@captype{table}}
makeatother
begin{document}
begin{longtable}{@{}c@{}}
caption{No Data}
endhead
endfoot
begin{minipage}{textwidth}
fixsubtable
subcaption{First subtable}
centering
rule{0.25textwidth}{0.25textwidth}
end{minipage}\
end{longtable}
end{document}
This does work if I place the caption and subcaption at the beginning of the minipage. However if I try to placesubcaption
in the style before row, as I was doing with the caption I get the error! Missing endgroup inserted.
. Your solution servers me right except for the fact that it increases the blank space between the subcaption and the subtable.
– fa__
Sep 5 at 7:28
I just noticed thebegin table=begin{longtable},
. There is no point in using longtable inside a minipage. If you have a subtable that needs to have pagebreaks, that is a more difficult problem.
– John Kormylo
Sep 5 at 12:46
I am usinglongtable
andpgfplotstableset
to process the data from a file in order to create a table with several subtables. I am using a minipage for every one of the subtables. That is, I need pagebreaks between the subtables, not in them.
– fa__
Sep 5 at 13:29
So stop usingbegin table=begin{longtable},
etc., which is causing every subtable to use longtable (and consequently disables subcaption again).
– John Kormylo
Sep 5 at 13:44
add a comment |
up vote
0
down vote
up vote
0
down vote
Only use fixsubtable
inside a minipage or other group.
documentclass{article}
usepackage{subcaption}
usepackage{longtable}
makeatletter
newcommand{fixsubtable}{letcaption=caption@caption
def@captype{table}}
makeatother
begin{document}
begin{longtable}{@{}c@{}}
caption{No Data}
endhead
endfoot
begin{minipage}{textwidth}
fixsubtable
subcaption{First subtable}
centering
rule{0.25textwidth}{0.25textwidth}
end{minipage}\
end{longtable}
end{document}
Only use fixsubtable
inside a minipage or other group.
documentclass{article}
usepackage{subcaption}
usepackage{longtable}
makeatletter
newcommand{fixsubtable}{letcaption=caption@caption
def@captype{table}}
makeatother
begin{document}
begin{longtable}{@{}c@{}}
caption{No Data}
endhead
endfoot
begin{minipage}{textwidth}
fixsubtable
subcaption{First subtable}
centering
rule{0.25textwidth}{0.25textwidth}
end{minipage}\
end{longtable}
end{document}
edited Sep 4 at 21:44
answered Sep 4 at 21:39
John Kormylo
43.4k12465
43.4k12465
This does work if I place the caption and subcaption at the beginning of the minipage. However if I try to placesubcaption
in the style before row, as I was doing with the caption I get the error! Missing endgroup inserted.
. Your solution servers me right except for the fact that it increases the blank space between the subcaption and the subtable.
– fa__
Sep 5 at 7:28
I just noticed thebegin table=begin{longtable},
. There is no point in using longtable inside a minipage. If you have a subtable that needs to have pagebreaks, that is a more difficult problem.
– John Kormylo
Sep 5 at 12:46
I am usinglongtable
andpgfplotstableset
to process the data from a file in order to create a table with several subtables. I am using a minipage for every one of the subtables. That is, I need pagebreaks between the subtables, not in them.
– fa__
Sep 5 at 13:29
So stop usingbegin table=begin{longtable},
etc., which is causing every subtable to use longtable (and consequently disables subcaption again).
– John Kormylo
Sep 5 at 13:44
add a comment |
This does work if I place the caption and subcaption at the beginning of the minipage. However if I try to placesubcaption
in the style before row, as I was doing with the caption I get the error! Missing endgroup inserted.
. Your solution servers me right except for the fact that it increases the blank space between the subcaption and the subtable.
– fa__
Sep 5 at 7:28
I just noticed thebegin table=begin{longtable},
. There is no point in using longtable inside a minipage. If you have a subtable that needs to have pagebreaks, that is a more difficult problem.
– John Kormylo
Sep 5 at 12:46
I am usinglongtable
andpgfplotstableset
to process the data from a file in order to create a table with several subtables. I am using a minipage for every one of the subtables. That is, I need pagebreaks between the subtables, not in them.
– fa__
Sep 5 at 13:29
So stop usingbegin table=begin{longtable},
etc., which is causing every subtable to use longtable (and consequently disables subcaption again).
– John Kormylo
Sep 5 at 13:44
This does work if I place the caption and subcaption at the beginning of the minipage. However if I try to place
subcaption
in the style before row, as I was doing with the caption I get the error ! Missing endgroup inserted.
. Your solution servers me right except for the fact that it increases the blank space between the subcaption and the subtable.– fa__
Sep 5 at 7:28
This does work if I place the caption and subcaption at the beginning of the minipage. However if I try to place
subcaption
in the style before row, as I was doing with the caption I get the error ! Missing endgroup inserted.
. Your solution servers me right except for the fact that it increases the blank space between the subcaption and the subtable.– fa__
Sep 5 at 7:28
I just noticed the
begin table=begin{longtable},
. There is no point in using longtable inside a minipage. If you have a subtable that needs to have pagebreaks, that is a more difficult problem.– John Kormylo
Sep 5 at 12:46
I just noticed the
begin table=begin{longtable},
. There is no point in using longtable inside a minipage. If you have a subtable that needs to have pagebreaks, that is a more difficult problem.– John Kormylo
Sep 5 at 12:46
I am using
longtable
and pgfplotstableset
to process the data from a file in order to create a table with several subtables. I am using a minipage for every one of the subtables. That is, I need pagebreaks between the subtables, not in them.– fa__
Sep 5 at 13:29
I am using
longtable
and pgfplotstableset
to process the data from a file in order to create a table with several subtables. I am using a minipage for every one of the subtables. That is, I need pagebreaks between the subtables, not in them.– fa__
Sep 5 at 13:29
So stop using
begin table=begin{longtable},
etc., which is causing every subtable to use longtable (and consequently disables subcaption again).– John Kormylo
Sep 5 at 13:44
So stop using
begin table=begin{longtable},
etc., which is causing every subtable to use longtable (and consequently disables subcaption again).– John Kormylo
Sep 5 at 13:44
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f449238%2fpgfplotstableset-longtable-and-subcaption%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How is it possible that
article.tex
has anend{table}
but nobegin{table}
(and does not have anend{document}
)? Please consider cleaning up your code such that others can start playing with it.– marmot
Sep 4 at 13:34
@marmot I am sorry about the mistake, I have changed it. The rest of the code has been copied directly from the minimal test I ran so there should be no more errors.
– fa__
Sep 4 at 13:53