TeX - LaTeX Asked on July 8, 2021
I’m trying to setup some corners ornamentations with the pgfornament package. It works, but the horizontal position of some of the ornamentations is wrong and I don’t know how to push them properly. Here’s a stripped down MWE version of my full castle of cards, that shows the issue:
documentclass[11pt,letterpaper,twoside]{book}
usepackage[T1]{fontenc}
usepackage[nomath]{lmodern}
usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
usepackage{microtype}
usepackage[bottom]{footmisc} % Options : [perpage], [symbol], [multiple]
usepackage{mathtools}
usepackage[dvipsnames,table]{xcolor}
usepackage[pagestyles,medium]{titlesec}
% Main header :
newpagestyle{principal}{
sethead[thepage][][itshapesmallMakeUppercase{chaptername thechapter. chaptertitle}]{itshapesmallMakeUppercase{thesection sectiontitle}}{}{thepage}
headrule
}
% Add a gray border :
usepackage{eso-pic}
definecolor{colorMarge}{RGB}{242,242,245}
newlength{distance}
setlength{distance}{0.0in} % 0.5in
newlength{rulethickness}
setlength{rulethickness}{0.5in} % 1pt
newlength{ruleheight}
setlength{ruleheight}{paperheight} % Longueur de la ligne
newlength{xoffset}
newlength{yoffset}
setlength{yoffset}{0pt} %{0.5dimexprpaperheight-ruleheight}
AddToShipoutPicture{%
setlengthfboxsep{1pt}% no additional frame for colorbox
ifoddvalue{page}%
setlength{xoffset}{distance}%
else
setlength{xoffset}{dimexprpaperwidth-rulethickness-distance}%
fi
AtPageLowerLeft{%
put(LenToUnit{xoffset},LenToUnit{yoffset}){%
colorbox{colorMarge}{parbox[b][ruleheight][c]{rulethickness}{%
centering
ifoddvalue{page}%
rotatebox[origin=cB]{90}{color{lightgray}{strut large{normalfonttextsc{Name and year}}}}%
else
rotatebox[origin=cB]{90}{color{lightgray}{strut huge{normalfonttextsc{Book Title}}}}%
fi}}}}%
}
% Add ornementations to corners :
usepackage[object=vectorian]{pgfornament}
makeatletter
AddToShipoutPicture{%
begingroup
setlength{@tempdima}{2mm}%
setlength{@tempdimb}{[email protected]}%
setlength{@tempdimc}{paperheight-@tempdima}%
put(LenToUnit{@tempdima},LenToUnit{@tempdimc}){%
pgfornament[anchor=north west,width=0.75in,color=gray]{41}}
put(LenToUnit{@tempdima},LenToUnit{@tempdima}){%
pgfornament[anchor=south west,width=0.75in,symmetry=h,color=gray]{41}}
put(LenToUnit{@tempdimb},LenToUnit{@tempdimc}){%
pgfornament[anchor=north east,width=0.75in,symmetry=v,color=gray]{41}}
put(LenToUnit{@tempdimb},LenToUnit{@tempdima}){%
pgfornament[anchor=south east,width=0.75in,symmetry=c,color=gray]{41}}
endgroup
}
makeatother
begin{document}
mainmatter
pagestyle{principal}
chapter{Chapter title}
Some funny linefootnote{Some weird footnote text.}
newpage
Another line
end{document}
Here’s a preview of what this code is doing (no, it’s not hacking the Central Bank of America), and the issue shown in red:
So I need to fix two things:
The ornamentations shouldn’t be inside the vertical gray region. They should be inside the margins, while the gray region (left and right pages) are reserved for some book informations and the pages binding.
The ornamentations should be used on all pages, but only for the main matter part of the book. There should be no ornamentations on any of the other pages (front matter and back matter).
So how could I fix both issues?
Just shift the ornaments in the same way as you did it for the grey margin box.
documentclass[11pt,letterpaper,twoside]{book}
usepackage{graphicx, xcolor, calc}
usepackage{eso-pic}
definecolor{colorMarge}{RGB}{242,242,245}
usepackage[object=vectorian]{pgfornament}
usepackage{lipsum}
newlengthmymargin
setlengthmymargin{0.5in}
newlengthmysize
setlengthmysize{1.5in}
newlengthmysep
setlengthmysep{6mm}
newcommandmybox[2][]{%
colorbox{colorMarge}{%
rotatebox[origin=l]{90}{%
parbox[c][mymargin][c]{paperheight}{%
centeringcolor{lightgray}normalfont #1 #2}}}}
newcommandleftornament[1]{%
put(LenToUnit{#1}, LenToUnit{mysep}){%
pgfornament[anchor=south, width=mysize, color=gray, symmetry=h]{41}}%
put(LenToUnit{#1}, LenToUnit{paperheight-mysep}){%
pgfornament[anchor=north, width=mysize, color=gray]{41}}}
newcommandrightornament[1]{%
put(LenToUnit{#1}, LenToUnit{mysep}){%
pgfornament[anchor=south, width=mysize, color=gray, symmetry=c]{41}}%
put(LenToUnit{#1}, LenToUnit{paperheight-mysep}){%
pgfornament[anchor=north, width=mysize, color=gray, symmetry=v]{41}}}
newcommandallOrnaments{%
setlengthfboxsep{0pt}%
ifoddvalue{page}%
put(0,0){mybox[scshapelarge]{Name and Year}}%
leftornament{mymargin+mysep}%
rightornament{paperwidth-mysize-mysep}%
else
put(LenToUnit{paperwidth-mymargin},0){mybox[scshapehuge]{Book Title}}%
leftornament{mysep}%
rightornament{paperwidth-mysize-mymargin-mysep}%
fi
}
newcommandstartOrnaments{AddToShipoutPicture{allOrnaments}}
newcommandstopOrnaments{ClearShipoutPicture}
begin{document}
frontmatter
chapter{Preface}
lipsum[1-5]
mainmatter
startOrnaments
chapter{Lorem ipsum}
lipsum[1-20]
backmatter
stopOrnaments
chapter{The End}
lipsum[1-5]
end{document}
Answered by Andreas Matthias on July 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP