Conditionals used in a new environment of detection of how many lines of quotation and with the selection of...
up vote
1
down vote
favorite
I would like that a new environment of quotation/quote detect how many lines a text has, then will increase or decrease the quotation length/margin.
For example:
newenvironment{citacao}[1]%
{list{}
% if a quotation has less than 3 lines, it will be set to 1.cm
ifthenelse{equal{citacao}{true}}
{%
setlength{citacao}{1.8cm}
}
% if a quotation has more than 3 lines, it will be set to 4cm
{% else
setlength{citacao}{4cm}
}
}%
{endlist}
If a new environment detects that a quotation has more than 3 lines, it will set the text to 4cm, if not, the text will be set to 1.8cm. Similar to:
newenvironment{citacao}[1]%
{list{}{leftmargin=1.8cmrightmargin=1.8cm}item}%
{endlist}
newenvironment{citacao}[1]%
{list{}{leftmargin=4cmrightmargin=4cm}item}%
{endlist}
I also would like to add the selection of a language for hyphenation like:
newenvironment{citacao}[1][english]%
{list{}{leftmargin=1.8cmrightmargin=1.8cm}item}%
{endlist}
I tried to code like:
newenvironment{citacao}[2]%
{selectotherlanguage[#1]list{}
% if a quotation has less than 3 lines, it will be set to 1.cm
ifthenelse{equal{citacao}{true}}
{%
setlength{citacao}{1.8cm}
}
% if a quotation has more than 3 lines, it will be set to 4cm
{% else
setlength{citacao}{4cm}
}
}%
{endlist}
Observe that I use XeLaTeX and the package csquotes
.
xetex environments conditionals quoting ifthenelse
add a comment |
up vote
1
down vote
favorite
I would like that a new environment of quotation/quote detect how many lines a text has, then will increase or decrease the quotation length/margin.
For example:
newenvironment{citacao}[1]%
{list{}
% if a quotation has less than 3 lines, it will be set to 1.cm
ifthenelse{equal{citacao}{true}}
{%
setlength{citacao}{1.8cm}
}
% if a quotation has more than 3 lines, it will be set to 4cm
{% else
setlength{citacao}{4cm}
}
}%
{endlist}
If a new environment detects that a quotation has more than 3 lines, it will set the text to 4cm, if not, the text will be set to 1.8cm. Similar to:
newenvironment{citacao}[1]%
{list{}{leftmargin=1.8cmrightmargin=1.8cm}item}%
{endlist}
newenvironment{citacao}[1]%
{list{}{leftmargin=4cmrightmargin=4cm}item}%
{endlist}
I also would like to add the selection of a language for hyphenation like:
newenvironment{citacao}[1][english]%
{list{}{leftmargin=1.8cmrightmargin=1.8cm}item}%
{endlist}
I tried to code like:
newenvironment{citacao}[2]%
{selectotherlanguage[#1]list{}
% if a quotation has less than 3 lines, it will be set to 1.cm
ifthenelse{equal{citacao}{true}}
{%
setlength{citacao}{1.8cm}
}
% if a quotation has more than 3 lines, it will be set to 4cm
{% else
setlength{citacao}{4cm}
}
}%
{endlist}
Observe that I use XeLaTeX and the package csquotes
.
xetex environments conditionals quoting ifthenelse
2
More than three lines under what line width?
– egreg
4 hours ago
It is under 4cm.
– Gustavo Reis
4 hours ago
You want to automate modifiedabnt
rules and make them look more rational. This is where good sense flies out of the window.
– Joseph
3 hours ago
@Joseph, actually, I usememoir
instead ofabntex2
, because I want to have much freedom to customise. I am using @gcedo'sThesis Polimi. The problem is that in his thesis, he usedcaption
andtitlesec
which are not good for the classmemoir
. As I use XeLaTeX,epstopdf
that he used in his package is not good for XeLaTeX. I have to look for the alternatives, to make them functional withbabel
,memoir
and XeLaTeX. I also usebiblatex-abnt
because I hatebibtex
andnatbib
.
– Gustavo Reis
2 hours ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I would like that a new environment of quotation/quote detect how many lines a text has, then will increase or decrease the quotation length/margin.
For example:
newenvironment{citacao}[1]%
{list{}
% if a quotation has less than 3 lines, it will be set to 1.cm
ifthenelse{equal{citacao}{true}}
{%
setlength{citacao}{1.8cm}
}
% if a quotation has more than 3 lines, it will be set to 4cm
{% else
setlength{citacao}{4cm}
}
}%
{endlist}
If a new environment detects that a quotation has more than 3 lines, it will set the text to 4cm, if not, the text will be set to 1.8cm. Similar to:
newenvironment{citacao}[1]%
{list{}{leftmargin=1.8cmrightmargin=1.8cm}item}%
{endlist}
newenvironment{citacao}[1]%
{list{}{leftmargin=4cmrightmargin=4cm}item}%
{endlist}
I also would like to add the selection of a language for hyphenation like:
newenvironment{citacao}[1][english]%
{list{}{leftmargin=1.8cmrightmargin=1.8cm}item}%
{endlist}
I tried to code like:
newenvironment{citacao}[2]%
{selectotherlanguage[#1]list{}
% if a quotation has less than 3 lines, it will be set to 1.cm
ifthenelse{equal{citacao}{true}}
{%
setlength{citacao}{1.8cm}
}
% if a quotation has more than 3 lines, it will be set to 4cm
{% else
setlength{citacao}{4cm}
}
}%
{endlist}
Observe that I use XeLaTeX and the package csquotes
.
xetex environments conditionals quoting ifthenelse
I would like that a new environment of quotation/quote detect how many lines a text has, then will increase or decrease the quotation length/margin.
For example:
newenvironment{citacao}[1]%
{list{}
% if a quotation has less than 3 lines, it will be set to 1.cm
ifthenelse{equal{citacao}{true}}
{%
setlength{citacao}{1.8cm}
}
% if a quotation has more than 3 lines, it will be set to 4cm
{% else
setlength{citacao}{4cm}
}
}%
{endlist}
If a new environment detects that a quotation has more than 3 lines, it will set the text to 4cm, if not, the text will be set to 1.8cm. Similar to:
newenvironment{citacao}[1]%
{list{}{leftmargin=1.8cmrightmargin=1.8cm}item}%
{endlist}
newenvironment{citacao}[1]%
{list{}{leftmargin=4cmrightmargin=4cm}item}%
{endlist}
I also would like to add the selection of a language for hyphenation like:
newenvironment{citacao}[1][english]%
{list{}{leftmargin=1.8cmrightmargin=1.8cm}item}%
{endlist}
I tried to code like:
newenvironment{citacao}[2]%
{selectotherlanguage[#1]list{}
% if a quotation has less than 3 lines, it will be set to 1.cm
ifthenelse{equal{citacao}{true}}
{%
setlength{citacao}{1.8cm}
}
% if a quotation has more than 3 lines, it will be set to 4cm
{% else
setlength{citacao}{4cm}
}
}%
{endlist}
Observe that I use XeLaTeX and the package csquotes
.
xetex environments conditionals quoting ifthenelse
xetex environments conditionals quoting ifthenelse
asked 4 hours ago
Gustavo Reis
185
185
2
More than three lines under what line width?
– egreg
4 hours ago
It is under 4cm.
– Gustavo Reis
4 hours ago
You want to automate modifiedabnt
rules and make them look more rational. This is where good sense flies out of the window.
– Joseph
3 hours ago
@Joseph, actually, I usememoir
instead ofabntex2
, because I want to have much freedom to customise. I am using @gcedo'sThesis Polimi. The problem is that in his thesis, he usedcaption
andtitlesec
which are not good for the classmemoir
. As I use XeLaTeX,epstopdf
that he used in his package is not good for XeLaTeX. I have to look for the alternatives, to make them functional withbabel
,memoir
and XeLaTeX. I also usebiblatex-abnt
because I hatebibtex
andnatbib
.
– Gustavo Reis
2 hours ago
add a comment |
2
More than three lines under what line width?
– egreg
4 hours ago
It is under 4cm.
– Gustavo Reis
4 hours ago
You want to automate modifiedabnt
rules and make them look more rational. This is where good sense flies out of the window.
– Joseph
3 hours ago
@Joseph, actually, I usememoir
instead ofabntex2
, because I want to have much freedom to customise. I am using @gcedo'sThesis Polimi. The problem is that in his thesis, he usedcaption
andtitlesec
which are not good for the classmemoir
. As I use XeLaTeX,epstopdf
that he used in his package is not good for XeLaTeX. I have to look for the alternatives, to make them functional withbabel
,memoir
and XeLaTeX. I also usebiblatex-abnt
because I hatebibtex
andnatbib
.
– Gustavo Reis
2 hours ago
2
2
More than three lines under what line width?
– egreg
4 hours ago
More than three lines under what line width?
– egreg
4 hours ago
It is under 4cm.
– Gustavo Reis
4 hours ago
It is under 4cm.
– Gustavo Reis
4 hours ago
You want to automate modified
abnt
rules and make them look more rational. This is where good sense flies out of the window.– Joseph
3 hours ago
You want to automate modified
abnt
rules and make them look more rational. This is where good sense flies out of the window.– Joseph
3 hours ago
@Joseph, actually, I use
memoir
instead of abntex2
, because I want to have much freedom to customise. I am using @gcedo'sThesis Polimi. The problem is that in his thesis, he used caption
and titlesec
which are not good for the class memoir
. As I use XeLaTeX, epstopdf
that he used in his package is not good for XeLaTeX. I have to look for the alternatives, to make them functional with babel
, memoir
and XeLaTeX. I also use biblatex-abnt
because I hate bibtex
and natbib
.– Gustavo Reis
2 hours ago
@Joseph, actually, I use
memoir
instead of abntex2
, because I want to have much freedom to customise. I am using @gcedo'sThesis Polimi. The problem is that in his thesis, he used caption
and titlesec
which are not good for the class memoir
. As I use XeLaTeX, epstopdf
that he used in his package is not good for XeLaTeX. I have to look for the alternatives, to make them functional with babel
, memoir
and XeLaTeX. I also use biblatex-abnt
because I hate bibtex
and natbib
.– Gustavo Reis
2 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
If your quotations are single paragraphs, this will work: the idea is to typeset the paragraph with the wide margins and use prevgraf
to know the number of lines. If the number is greater than 3, the margin is reduced when calling list
.
The same idea could be used for multiparagraph quotations, with some complications.
documentclass{article}
usepackage[latin,english]{babel}
usepackage{fontspec}
usepackage{environ}
newlength{citacaoindent}
setlength{citacaoindent}{4cm}
NewEnviron{citacao}[1][english]{%
csname otherlanguage*endcsname{#1}%
setbox0=vbox{
hsize=dimexprhsize-2citacaoindentrelax
BODYparexpandafter
}expandafterifnumtheprevgraf>3 setlength{citacaoindent}{1.8cm}fi
list{}{leftmargin=citacaoindent rightmargin=citacaoindent}
itemBODY
endlist
}
begin{document}
begin{citacao}
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
begin{citacao}[latin]
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}[latin]
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
end{document}
Sorry for having forgotten that I usebabel
instead ofpolyglossia
. Dosetmainlanguage
andsetotherlanguage
workbabel
?
– Gustavo Reis
3 hours ago
@GustavoReis No, but the code works the same if you remove thepolyglossia
settings and dousepackage[latin,english]{babel}
. I changed the code.
– egreg
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
If your quotations are single paragraphs, this will work: the idea is to typeset the paragraph with the wide margins and use prevgraf
to know the number of lines. If the number is greater than 3, the margin is reduced when calling list
.
The same idea could be used for multiparagraph quotations, with some complications.
documentclass{article}
usepackage[latin,english]{babel}
usepackage{fontspec}
usepackage{environ}
newlength{citacaoindent}
setlength{citacaoindent}{4cm}
NewEnviron{citacao}[1][english]{%
csname otherlanguage*endcsname{#1}%
setbox0=vbox{
hsize=dimexprhsize-2citacaoindentrelax
BODYparexpandafter
}expandafterifnumtheprevgraf>3 setlength{citacaoindent}{1.8cm}fi
list{}{leftmargin=citacaoindent rightmargin=citacaoindent}
itemBODY
endlist
}
begin{document}
begin{citacao}
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
begin{citacao}[latin]
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}[latin]
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
end{document}
Sorry for having forgotten that I usebabel
instead ofpolyglossia
. Dosetmainlanguage
andsetotherlanguage
workbabel
?
– Gustavo Reis
3 hours ago
@GustavoReis No, but the code works the same if you remove thepolyglossia
settings and dousepackage[latin,english]{babel}
. I changed the code.
– egreg
3 hours ago
add a comment |
up vote
2
down vote
accepted
If your quotations are single paragraphs, this will work: the idea is to typeset the paragraph with the wide margins and use prevgraf
to know the number of lines. If the number is greater than 3, the margin is reduced when calling list
.
The same idea could be used for multiparagraph quotations, with some complications.
documentclass{article}
usepackage[latin,english]{babel}
usepackage{fontspec}
usepackage{environ}
newlength{citacaoindent}
setlength{citacaoindent}{4cm}
NewEnviron{citacao}[1][english]{%
csname otherlanguage*endcsname{#1}%
setbox0=vbox{
hsize=dimexprhsize-2citacaoindentrelax
BODYparexpandafter
}expandafterifnumtheprevgraf>3 setlength{citacaoindent}{1.8cm}fi
list{}{leftmargin=citacaoindent rightmargin=citacaoindent}
itemBODY
endlist
}
begin{document}
begin{citacao}
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
begin{citacao}[latin]
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}[latin]
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
end{document}
Sorry for having forgotten that I usebabel
instead ofpolyglossia
. Dosetmainlanguage
andsetotherlanguage
workbabel
?
– Gustavo Reis
3 hours ago
@GustavoReis No, but the code works the same if you remove thepolyglossia
settings and dousepackage[latin,english]{babel}
. I changed the code.
– egreg
3 hours ago
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
If your quotations are single paragraphs, this will work: the idea is to typeset the paragraph with the wide margins and use prevgraf
to know the number of lines. If the number is greater than 3, the margin is reduced when calling list
.
The same idea could be used for multiparagraph quotations, with some complications.
documentclass{article}
usepackage[latin,english]{babel}
usepackage{fontspec}
usepackage{environ}
newlength{citacaoindent}
setlength{citacaoindent}{4cm}
NewEnviron{citacao}[1][english]{%
csname otherlanguage*endcsname{#1}%
setbox0=vbox{
hsize=dimexprhsize-2citacaoindentrelax
BODYparexpandafter
}expandafterifnumtheprevgraf>3 setlength{citacaoindent}{1.8cm}fi
list{}{leftmargin=citacaoindent rightmargin=citacaoindent}
itemBODY
endlist
}
begin{document}
begin{citacao}
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
begin{citacao}[latin]
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}[latin]
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
end{document}
If your quotations are single paragraphs, this will work: the idea is to typeset the paragraph with the wide margins and use prevgraf
to know the number of lines. If the number is greater than 3, the margin is reduced when calling list
.
The same idea could be used for multiparagraph quotations, with some complications.
documentclass{article}
usepackage[latin,english]{babel}
usepackage{fontspec}
usepackage{environ}
newlength{citacaoindent}
setlength{citacaoindent}{4cm}
NewEnviron{citacao}[1][english]{%
csname otherlanguage*endcsname{#1}%
setbox0=vbox{
hsize=dimexprhsize-2citacaoindentrelax
BODYparexpandafter
}expandafterifnumtheprevgraf>3 setlength{citacaoindent}{1.8cm}fi
list{}{leftmargin=citacaoindent rightmargin=citacaoindent}
itemBODY
endlist
}
begin{document}
begin{citacao}
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
begin{citacao}[latin]
This is a short quotation in languagename,
typeset with a wide margin.
end{citacao}
begin{citacao}[latin]
This is a long quotation in languagename, that should be
typeset with a narrower margin
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines
because it fills more than three lines.
end{citacao}
end{document}
edited 3 hours ago
answered 3 hours ago
egreg
699k8518583127
699k8518583127
Sorry for having forgotten that I usebabel
instead ofpolyglossia
. Dosetmainlanguage
andsetotherlanguage
workbabel
?
– Gustavo Reis
3 hours ago
@GustavoReis No, but the code works the same if you remove thepolyglossia
settings and dousepackage[latin,english]{babel}
. I changed the code.
– egreg
3 hours ago
add a comment |
Sorry for having forgotten that I usebabel
instead ofpolyglossia
. Dosetmainlanguage
andsetotherlanguage
workbabel
?
– Gustavo Reis
3 hours ago
@GustavoReis No, but the code works the same if you remove thepolyglossia
settings and dousepackage[latin,english]{babel}
. I changed the code.
– egreg
3 hours ago
Sorry for having forgotten that I use
babel
instead of polyglossia
. Do setmainlanguage
and setotherlanguage
work babel
?– Gustavo Reis
3 hours ago
Sorry for having forgotten that I use
babel
instead of polyglossia
. Do setmainlanguage
and setotherlanguage
work babel
?– Gustavo Reis
3 hours ago
@GustavoReis No, but the code works the same if you remove the
polyglossia
settings and do usepackage[latin,english]{babel}
. I changed the code.– egreg
3 hours ago
@GustavoReis No, but the code works the same if you remove the
polyglossia
settings and do usepackage[latin,english]{babel}
. I changed the code.– egreg
3 hours ago
add a comment |
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%2f461354%2fconditionals-used-in-a-new-environment-of-detection-of-how-many-lines-of-quotati%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
2
More than three lines under what line width?
– egreg
4 hours ago
It is under 4cm.
– Gustavo Reis
4 hours ago
You want to automate modified
abnt
rules and make them look more rational. This is where good sense flies out of the window.– Joseph
3 hours ago
@Joseph, actually, I use
memoir
instead ofabntex2
, because I want to have much freedom to customise. I am using @gcedo'sThesis Polimi. The problem is that in his thesis, he usedcaption
andtitlesec
which are not good for the classmemoir
. As I use XeLaTeX,epstopdf
that he used in his package is not good for XeLaTeX. I have to look for the alternatives, to make them functional withbabel
,memoir
and XeLaTeX. I also usebiblatex-abnt
because I hatebibtex
andnatbib
.– Gustavo Reis
2 hours ago