How to create a horizontal line above and below an entire table environment?
I have several tables in a document and I would like to add a horizontal line across the page above and below the entire table
environment. I can get the desired output with hrule
and some extra spacing, but I'd like to be able to define a format that does this to use for all tables, rather than manually add the lines. Here's an example of my desired output:
documentclass{article}
usepackage[tableposition=top]{caption}
usepackage{float}
floatstyle{plaintop}
restylefloat{table}
begin{document}
text
vspace{5mm}hrule
begin{table}[H]
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something}
label{something}
end{table}
hrulevspace{5mm}
text
end{document}
Thanks
Edit: Additionally, is there a way to change the spacing depending on whether the following content is text or an equation? If I had an equation instead of text either directly above or directly below the table, I would remove the corresponding vspace{5mm}
.
tables
add a comment |
I have several tables in a document and I would like to add a horizontal line across the page above and below the entire table
environment. I can get the desired output with hrule
and some extra spacing, but I'd like to be able to define a format that does this to use for all tables, rather than manually add the lines. Here's an example of my desired output:
documentclass{article}
usepackage[tableposition=top]{caption}
usepackage{float}
floatstyle{plaintop}
restylefloat{table}
begin{document}
text
vspace{5mm}hrule
begin{table}[H]
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something}
label{something}
end{table}
hrulevspace{5mm}
text
end{document}
Thanks
Edit: Additionally, is there a way to change the spacing depending on whether the following content is text or an equation? If I had an equation instead of text either directly above or directly below the table, I would remove the corresponding vspace{5mm}
.
tables
add a comment |
I have several tables in a document and I would like to add a horizontal line across the page above and below the entire table
environment. I can get the desired output with hrule
and some extra spacing, but I'd like to be able to define a format that does this to use for all tables, rather than manually add the lines. Here's an example of my desired output:
documentclass{article}
usepackage[tableposition=top]{caption}
usepackage{float}
floatstyle{plaintop}
restylefloat{table}
begin{document}
text
vspace{5mm}hrule
begin{table}[H]
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something}
label{something}
end{table}
hrulevspace{5mm}
text
end{document}
Thanks
Edit: Additionally, is there a way to change the spacing depending on whether the following content is text or an equation? If I had an equation instead of text either directly above or directly below the table, I would remove the corresponding vspace{5mm}
.
tables
I have several tables in a document and I would like to add a horizontal line across the page above and below the entire table
environment. I can get the desired output with hrule
and some extra spacing, but I'd like to be able to define a format that does this to use for all tables, rather than manually add the lines. Here's an example of my desired output:
documentclass{article}
usepackage[tableposition=top]{caption}
usepackage{float}
floatstyle{plaintop}
restylefloat{table}
begin{document}
text
vspace{5mm}hrule
begin{table}[H]
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something}
label{something}
end{table}
hrulevspace{5mm}
text
end{document}
Thanks
Edit: Additionally, is there a way to change the spacing depending on whether the following content is text or an equation? If I had an equation instead of text either directly above or directly below the table, I would remove the corresponding vspace{5mm}
.
tables
tables
edited Dec 8 at 20:55
asked Dec 8 at 20:44
MathIsFun
625
625
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Using the environ
package, you can define your own table
environment based off of the original table
plus your required additions. The ruledtable
, e.g., can be defined like this:
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
In this case, you will only change all instances of begin{table} .. end{table}
in your text to the new begin{ruledtable} .. end{ruledtable}
without any additional manual modifications.
documentclass{article}
usepackage[tableposition=top]{caption}
usepackage{float}
floatstyle{plaintop}
restylefloat{table}
usepackage{environ}
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
begin{document}
text
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something}
label{something}
end{ruledtable}
text
begin{equation}
x + y = 5
end{equation}
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something2}
label{something2}
end{ruledtable}
begin{equation}
x + y = 5
end{equation}
end{document}
Thank you, this works!addvspace
seems like a useful command.
– MathIsFun
Dec 8 at 21:26
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f463861%2fhow-to-create-a-horizontal-line-above-and-below-an-entire-table-environment%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using the environ
package, you can define your own table
environment based off of the original table
plus your required additions. The ruledtable
, e.g., can be defined like this:
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
In this case, you will only change all instances of begin{table} .. end{table}
in your text to the new begin{ruledtable} .. end{ruledtable}
without any additional manual modifications.
documentclass{article}
usepackage[tableposition=top]{caption}
usepackage{float}
floatstyle{plaintop}
restylefloat{table}
usepackage{environ}
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
begin{document}
text
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something}
label{something}
end{ruledtable}
text
begin{equation}
x + y = 5
end{equation}
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something2}
label{something2}
end{ruledtable}
begin{equation}
x + y = 5
end{equation}
end{document}
Thank you, this works!addvspace
seems like a useful command.
– MathIsFun
Dec 8 at 21:26
add a comment |
Using the environ
package, you can define your own table
environment based off of the original table
plus your required additions. The ruledtable
, e.g., can be defined like this:
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
In this case, you will only change all instances of begin{table} .. end{table}
in your text to the new begin{ruledtable} .. end{ruledtable}
without any additional manual modifications.
documentclass{article}
usepackage[tableposition=top]{caption}
usepackage{float}
floatstyle{plaintop}
restylefloat{table}
usepackage{environ}
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
begin{document}
text
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something}
label{something}
end{ruledtable}
text
begin{equation}
x + y = 5
end{equation}
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something2}
label{something2}
end{ruledtable}
begin{equation}
x + y = 5
end{equation}
end{document}
Thank you, this works!addvspace
seems like a useful command.
– MathIsFun
Dec 8 at 21:26
add a comment |
Using the environ
package, you can define your own table
environment based off of the original table
plus your required additions. The ruledtable
, e.g., can be defined like this:
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
In this case, you will only change all instances of begin{table} .. end{table}
in your text to the new begin{ruledtable} .. end{ruledtable}
without any additional manual modifications.
documentclass{article}
usepackage[tableposition=top]{caption}
usepackage{float}
floatstyle{plaintop}
restylefloat{table}
usepackage{environ}
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
begin{document}
text
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something}
label{something}
end{ruledtable}
text
begin{equation}
x + y = 5
end{equation}
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something2}
label{something2}
end{ruledtable}
begin{equation}
x + y = 5
end{equation}
end{document}
Using the environ
package, you can define your own table
environment based off of the original table
plus your required additions. The ruledtable
, e.g., can be defined like this:
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
In this case, you will only change all instances of begin{table} .. end{table}
in your text to the new begin{ruledtable} .. end{ruledtable}
without any additional manual modifications.
documentclass{article}
usepackage[tableposition=top]{caption}
usepackage{float}
floatstyle{plaintop}
restylefloat{table}
usepackage{environ}
NewEnviron{ruledtable}{%
paraddvspace{5mm}hrule
begin{table}[!h]BODYend{table}
hruleaddvspace{5mm}
}
begin{document}
text
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something}
label{something}
end{ruledtable}
text
begin{equation}
x + y = 5
end{equation}
begin{ruledtable}
centering
begin{tabular}{c|c}
a & a\
a & a
end{tabular}
caption{something2}
label{something2}
end{ruledtable}
begin{equation}
x + y = 5
end{equation}
end{document}
edited Dec 8 at 21:22
answered Dec 8 at 21:16
AboAmmar
32.9k22882
32.9k22882
Thank you, this works!addvspace
seems like a useful command.
– MathIsFun
Dec 8 at 21:26
add a comment |
Thank you, this works!addvspace
seems like a useful command.
– MathIsFun
Dec 8 at 21:26
Thank you, this works!
addvspace
seems like a useful command.– MathIsFun
Dec 8 at 21:26
Thank you, this works!
addvspace
seems like a useful command.– MathIsFun
Dec 8 at 21:26
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%2f463861%2fhow-to-create-a-horizontal-line-above-and-below-an-entire-table-environment%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