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.










share|improve this question


















  • 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 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















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.










share|improve this question


















  • 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 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













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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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














  • 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 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








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










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}


enter image description here






share|improve this answer























  • 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













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
});


}
});














 

draft saved


draft discarded


















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

























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}


enter image description here






share|improve this answer























  • 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

















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}


enter image description here






share|improve this answer























  • 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















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}


enter image description here






share|improve this answer














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}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 3 hours ago

























answered 3 hours ago









egreg

699k8518583127




699k8518583127












  • 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




















  • 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


















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




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)