How to make a new environment based on a given table
up vote
1
down vote
favorite
I want to make an environment obj
(numbered by chapter) such that the command
begin{obj}{Text 1}
Text 2
end{obj}
generates the following (assuming that this is the first obj
environment in chapter 1) :
documentclass{report}
usepackage[table]{xcolor}
usepackage{tabularx,booktabs}
usepackage{array}
newcolumntype{/}{!{textcolor{myblue}{vrule width 1.5pt}}}
newlength{Oldarrayrulewidth}
newcommand{Cline}[2]{%
noalign{globalsetlength{Oldarrayrulewidth}{arrayrulewidth}}%
noalign{globalsetlength{arrayrulewidth}{#1}}cline{#2}%
noalign{globalsetlength{arrayrulewidth}{Oldarrayrulewidth}}}
definecolor{myblue}{RGB}{32,92,195}
arrayrulecolor{myblue}
begin{document}
begin{center}
begin{tabularx}{textwidth}{ p{0.25in} p{0.05in} X }
textcolor{myblue}{textbf{1.1}} & multicolumn{2}{X}{textcolor{myblue}{Text 1}} \
Cline{2.5pt}{1-3}
& multicolumn{1}{/p{0.05in}}{} & multicolumn{1}{X}{vspace{0.0pt}
Text 2} \
Cline{1.5pt}{2-3}
end{tabularx}
end{center}
end{document}
tables environments
add a comment |
up vote
1
down vote
favorite
I want to make an environment obj
(numbered by chapter) such that the command
begin{obj}{Text 1}
Text 2
end{obj}
generates the following (assuming that this is the first obj
environment in chapter 1) :
documentclass{report}
usepackage[table]{xcolor}
usepackage{tabularx,booktabs}
usepackage{array}
newcolumntype{/}{!{textcolor{myblue}{vrule width 1.5pt}}}
newlength{Oldarrayrulewidth}
newcommand{Cline}[2]{%
noalign{globalsetlength{Oldarrayrulewidth}{arrayrulewidth}}%
noalign{globalsetlength{arrayrulewidth}{#1}}cline{#2}%
noalign{globalsetlength{arrayrulewidth}{Oldarrayrulewidth}}}
definecolor{myblue}{RGB}{32,92,195}
arrayrulecolor{myblue}
begin{document}
begin{center}
begin{tabularx}{textwidth}{ p{0.25in} p{0.05in} X }
textcolor{myblue}{textbf{1.1}} & multicolumn{2}{X}{textcolor{myblue}{Text 1}} \
Cline{2.5pt}{1-3}
& multicolumn{1}{/p{0.05in}}{} & multicolumn{1}{X}{vspace{0.0pt}
Text 2} \
Cline{1.5pt}{2-3}
end{tabularx}
end{center}
end{document}
tables environments
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to make an environment obj
(numbered by chapter) such that the command
begin{obj}{Text 1}
Text 2
end{obj}
generates the following (assuming that this is the first obj
environment in chapter 1) :
documentclass{report}
usepackage[table]{xcolor}
usepackage{tabularx,booktabs}
usepackage{array}
newcolumntype{/}{!{textcolor{myblue}{vrule width 1.5pt}}}
newlength{Oldarrayrulewidth}
newcommand{Cline}[2]{%
noalign{globalsetlength{Oldarrayrulewidth}{arrayrulewidth}}%
noalign{globalsetlength{arrayrulewidth}{#1}}cline{#2}%
noalign{globalsetlength{arrayrulewidth}{Oldarrayrulewidth}}}
definecolor{myblue}{RGB}{32,92,195}
arrayrulecolor{myblue}
begin{document}
begin{center}
begin{tabularx}{textwidth}{ p{0.25in} p{0.05in} X }
textcolor{myblue}{textbf{1.1}} & multicolumn{2}{X}{textcolor{myblue}{Text 1}} \
Cline{2.5pt}{1-3}
& multicolumn{1}{/p{0.05in}}{} & multicolumn{1}{X}{vspace{0.0pt}
Text 2} \
Cline{1.5pt}{2-3}
end{tabularx}
end{center}
end{document}
tables environments
I want to make an environment obj
(numbered by chapter) such that the command
begin{obj}{Text 1}
Text 2
end{obj}
generates the following (assuming that this is the first obj
environment in chapter 1) :
documentclass{report}
usepackage[table]{xcolor}
usepackage{tabularx,booktabs}
usepackage{array}
newcolumntype{/}{!{textcolor{myblue}{vrule width 1.5pt}}}
newlength{Oldarrayrulewidth}
newcommand{Cline}[2]{%
noalign{globalsetlength{Oldarrayrulewidth}{arrayrulewidth}}%
noalign{globalsetlength{arrayrulewidth}{#1}}cline{#2}%
noalign{globalsetlength{arrayrulewidth}{Oldarrayrulewidth}}}
definecolor{myblue}{RGB}{32,92,195}
arrayrulecolor{myblue}
begin{document}
begin{center}
begin{tabularx}{textwidth}{ p{0.25in} p{0.05in} X }
textcolor{myblue}{textbf{1.1}} & multicolumn{2}{X}{textcolor{myblue}{Text 1}} \
Cline{2.5pt}{1-3}
& multicolumn{1}{/p{0.05in}}{} & multicolumn{1}{X}{vspace{0.0pt}
Text 2} \
Cline{1.5pt}{2-3}
end{tabularx}
end{center}
end{document}
tables environments
tables environments
asked Dec 6 at 11:50
simple jack
62
62
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
It's slightly easier to do this as a macro:
documentclass{report}
usepackage[table]{xcolor}
usepackage{tabularx,booktabs}
usepackage{array}
newcolumntype{/}{!{textcolor{myblue}{vrule width 1.5pt}}}
newlength{Oldarrayrulewidth}
newcommand{Cline}[2]{%
noalign{globalsetlength{Oldarrayrulewidth}{arrayrulewidth}}%
noalign{globalsetlength{arrayrulewidth}{#1}}cline{#2}%
noalign{globalsetlength{arrayrulewidth}{Oldarrayrulewidth}}}
definecolor{myblue}{RGB}{32,92,195}
arrayrulecolor{myblue}
newcounter{object}[chapter]
renewcommandtheobject{thechapter.arabic{object}}
newcommandobj[2]{%
refstepcounter{object}
begin{center}
begin{tabularx}{textwidth}{ p{0.25in} p{0.05in} X }
textcolor{myblue}{textbf{theobject}} & multicolumn{2}{X}{textcolor{myblue}{#1}} \
Cline{2.5pt}{1-3}
& multicolumn{1}{/p{0.05in}}{} & multicolumn{1}{X}{vspace{0.0pt}
#2} \
Cline{1.5pt}{2-3}
end{tabularx}
end{center}
}
begin{document}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
end{document}
will produce (for the second chapter):
I agree, the macro is better. Can you make it automatically numbered within each chapter like a theorem ? I don't want all of them to be numbered "1.1". That would defeat the point of the macro.
– simple jack
Dec 6 at 13:15
Also I get a lot of error messages on line 23endtabularxend{center}}
including "missingbegin{document}
". It doesn't compile for me.
– simple jack
Dec 6 at 13:21
@simplejack Sorry, missed the counter requirement. Not sure why there was a compilation error before either...both fixed now.
– Andrew
Dec 6 at 20:32
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',
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%2f463503%2fhow-to-make-a-new-environment-based-on-a-given-table%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
up vote
1
down vote
It's slightly easier to do this as a macro:
documentclass{report}
usepackage[table]{xcolor}
usepackage{tabularx,booktabs}
usepackage{array}
newcolumntype{/}{!{textcolor{myblue}{vrule width 1.5pt}}}
newlength{Oldarrayrulewidth}
newcommand{Cline}[2]{%
noalign{globalsetlength{Oldarrayrulewidth}{arrayrulewidth}}%
noalign{globalsetlength{arrayrulewidth}{#1}}cline{#2}%
noalign{globalsetlength{arrayrulewidth}{Oldarrayrulewidth}}}
definecolor{myblue}{RGB}{32,92,195}
arrayrulecolor{myblue}
newcounter{object}[chapter]
renewcommandtheobject{thechapter.arabic{object}}
newcommandobj[2]{%
refstepcounter{object}
begin{center}
begin{tabularx}{textwidth}{ p{0.25in} p{0.05in} X }
textcolor{myblue}{textbf{theobject}} & multicolumn{2}{X}{textcolor{myblue}{#1}} \
Cline{2.5pt}{1-3}
& multicolumn{1}{/p{0.05in}}{} & multicolumn{1}{X}{vspace{0.0pt}
#2} \
Cline{1.5pt}{2-3}
end{tabularx}
end{center}
}
begin{document}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
end{document}
will produce (for the second chapter):
I agree, the macro is better. Can you make it automatically numbered within each chapter like a theorem ? I don't want all of them to be numbered "1.1". That would defeat the point of the macro.
– simple jack
Dec 6 at 13:15
Also I get a lot of error messages on line 23endtabularxend{center}}
including "missingbegin{document}
". It doesn't compile for me.
– simple jack
Dec 6 at 13:21
@simplejack Sorry, missed the counter requirement. Not sure why there was a compilation error before either...both fixed now.
– Andrew
Dec 6 at 20:32
add a comment |
up vote
1
down vote
It's slightly easier to do this as a macro:
documentclass{report}
usepackage[table]{xcolor}
usepackage{tabularx,booktabs}
usepackage{array}
newcolumntype{/}{!{textcolor{myblue}{vrule width 1.5pt}}}
newlength{Oldarrayrulewidth}
newcommand{Cline}[2]{%
noalign{globalsetlength{Oldarrayrulewidth}{arrayrulewidth}}%
noalign{globalsetlength{arrayrulewidth}{#1}}cline{#2}%
noalign{globalsetlength{arrayrulewidth}{Oldarrayrulewidth}}}
definecolor{myblue}{RGB}{32,92,195}
arrayrulecolor{myblue}
newcounter{object}[chapter]
renewcommandtheobject{thechapter.arabic{object}}
newcommandobj[2]{%
refstepcounter{object}
begin{center}
begin{tabularx}{textwidth}{ p{0.25in} p{0.05in} X }
textcolor{myblue}{textbf{theobject}} & multicolumn{2}{X}{textcolor{myblue}{#1}} \
Cline{2.5pt}{1-3}
& multicolumn{1}{/p{0.05in}}{} & multicolumn{1}{X}{vspace{0.0pt}
#2} \
Cline{1.5pt}{2-3}
end{tabularx}
end{center}
}
begin{document}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
end{document}
will produce (for the second chapter):
I agree, the macro is better. Can you make it automatically numbered within each chapter like a theorem ? I don't want all of them to be numbered "1.1". That would defeat the point of the macro.
– simple jack
Dec 6 at 13:15
Also I get a lot of error messages on line 23endtabularxend{center}}
including "missingbegin{document}
". It doesn't compile for me.
– simple jack
Dec 6 at 13:21
@simplejack Sorry, missed the counter requirement. Not sure why there was a compilation error before either...both fixed now.
– Andrew
Dec 6 at 20:32
add a comment |
up vote
1
down vote
up vote
1
down vote
It's slightly easier to do this as a macro:
documentclass{report}
usepackage[table]{xcolor}
usepackage{tabularx,booktabs}
usepackage{array}
newcolumntype{/}{!{textcolor{myblue}{vrule width 1.5pt}}}
newlength{Oldarrayrulewidth}
newcommand{Cline}[2]{%
noalign{globalsetlength{Oldarrayrulewidth}{arrayrulewidth}}%
noalign{globalsetlength{arrayrulewidth}{#1}}cline{#2}%
noalign{globalsetlength{arrayrulewidth}{Oldarrayrulewidth}}}
definecolor{myblue}{RGB}{32,92,195}
arrayrulecolor{myblue}
newcounter{object}[chapter]
renewcommandtheobject{thechapter.arabic{object}}
newcommandobj[2]{%
refstepcounter{object}
begin{center}
begin{tabularx}{textwidth}{ p{0.25in} p{0.05in} X }
textcolor{myblue}{textbf{theobject}} & multicolumn{2}{X}{textcolor{myblue}{#1}} \
Cline{2.5pt}{1-3}
& multicolumn{1}{/p{0.05in}}{} & multicolumn{1}{X}{vspace{0.0pt}
#2} \
Cline{1.5pt}{2-3}
end{tabularx}
end{center}
}
begin{document}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
end{document}
will produce (for the second chapter):
It's slightly easier to do this as a macro:
documentclass{report}
usepackage[table]{xcolor}
usepackage{tabularx,booktabs}
usepackage{array}
newcolumntype{/}{!{textcolor{myblue}{vrule width 1.5pt}}}
newlength{Oldarrayrulewidth}
newcommand{Cline}[2]{%
noalign{globalsetlength{Oldarrayrulewidth}{arrayrulewidth}}%
noalign{globalsetlength{arrayrulewidth}{#1}}cline{#2}%
noalign{globalsetlength{arrayrulewidth}{Oldarrayrulewidth}}}
definecolor{myblue}{RGB}{32,92,195}
arrayrulecolor{myblue}
newcounter{object}[chapter]
renewcommandtheobject{thechapter.arabic{object}}
newcommandobj[2]{%
refstepcounter{object}
begin{center}
begin{tabularx}{textwidth}{ p{0.25in} p{0.05in} X }
textcolor{myblue}{textbf{theobject}} & multicolumn{2}{X}{textcolor{myblue}{#1}} \
Cline{2.5pt}{1-3}
& multicolumn{1}{/p{0.05in}}{} & multicolumn{1}{X}{vspace{0.0pt}
#2} \
Cline{1.5pt}{2-3}
end{tabularx}
end{center}
}
begin{document}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
chapter{Some chapter}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
obj{Text 1}{Text 2}
end{document}
will produce (for the second chapter):
edited Dec 6 at 20:32
answered Dec 6 at 13:10
Andrew
30.3k34380
30.3k34380
I agree, the macro is better. Can you make it automatically numbered within each chapter like a theorem ? I don't want all of them to be numbered "1.1". That would defeat the point of the macro.
– simple jack
Dec 6 at 13:15
Also I get a lot of error messages on line 23endtabularxend{center}}
including "missingbegin{document}
". It doesn't compile for me.
– simple jack
Dec 6 at 13:21
@simplejack Sorry, missed the counter requirement. Not sure why there was a compilation error before either...both fixed now.
– Andrew
Dec 6 at 20:32
add a comment |
I agree, the macro is better. Can you make it automatically numbered within each chapter like a theorem ? I don't want all of them to be numbered "1.1". That would defeat the point of the macro.
– simple jack
Dec 6 at 13:15
Also I get a lot of error messages on line 23endtabularxend{center}}
including "missingbegin{document}
". It doesn't compile for me.
– simple jack
Dec 6 at 13:21
@simplejack Sorry, missed the counter requirement. Not sure why there was a compilation error before either...both fixed now.
– Andrew
Dec 6 at 20:32
I agree, the macro is better. Can you make it automatically numbered within each chapter like a theorem ? I don't want all of them to be numbered "1.1". That would defeat the point of the macro.
– simple jack
Dec 6 at 13:15
I agree, the macro is better. Can you make it automatically numbered within each chapter like a theorem ? I don't want all of them to be numbered "1.1". That would defeat the point of the macro.
– simple jack
Dec 6 at 13:15
Also I get a lot of error messages on line 23
endtabularxend{center}}
including "missing begin{document}
". It doesn't compile for me.– simple jack
Dec 6 at 13:21
Also I get a lot of error messages on line 23
endtabularxend{center}}
including "missing begin{document}
". It doesn't compile for me.– simple jack
Dec 6 at 13:21
@simplejack Sorry, missed the counter requirement. Not sure why there was a compilation error before either...both fixed now.
– Andrew
Dec 6 at 20:32
@simplejack Sorry, missed the counter requirement. Not sure why there was a compilation error before either...both fixed now.
– Andrew
Dec 6 at 20:32
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%2f463503%2fhow-to-make-a-new-environment-based-on-a-given-table%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