TeX - LaTeX Asked by HerculePoivrot on March 30, 2021
This is my third question in 2 days but Im struggling with a problem and I have the feeling I’m not far from finally solving it, but cannot figure it out myself.
I have a document for my students who is in two versions : one with blanks for the students and one for me with filled blanks. I had some working macros to do that but I wanted that the space in the space is the exact same for the 2 versions so that the page numbers are the same.
I was advised here : Hiding part of the document under conditions
to simply write in the background color my text and add a space after for the students. I tried that.
But the problem is that my examples where are my blanks are inside tcolorboxes. But tcolorboxes kills color when the page breaks as was stated here : Keep font color in a breakable tcolorbox
I decided to try the recommanded solution with fontspec. I never used LuaLateX and but the document run smoothly.
However, after looking quite some time on the internet, on here and trying to understand the very obscure documentation of the fontspec package, I cannot make it work the way I’d like. Here is the quickest sample I could produce.
documentclass{article}
usepackage{fontspec}
usepackage{xcolor}
usepackage{amsmath}
usepackage{amssymb}
usepackage[most]{tcolorbox}
usepackage{ifthen}
usepackage{enumitem}
usepackage{array}
newcounter{current}
setcounter{current}{1}
newcommand{module}[1]{lvert#1rvert}
newcommand{exemples}[1]{
begin{tcolorbox}[breakable,colframe=gray!10,colback=gray!10]
textbf{Exemples thechapter.thecurrent}
begin{enumerate}[label=(arabic*),wide]
#1
end{enumerate}
end{tcolorbox}
stepcounter{current}
}
newcommand{hide}[1]{
ifthenelse{equal{edition}{E}}{
color{gray!10}
%here is the fontspec code I should include
#1
color{black}
}
{
}
}
begin{document}
sffamily
exemples{
item Résoudre l'équation $z^2+(4+7i)cdot z-31-i=0$
defedition{E}
hide{On a : $begin{array}[t]{ccl}Delta&=&(4+7i)^2-4cdot1cdot(-31- i)
&=&16-49+56i+124+4i
&=&91+60i
end{array}$
On doit donc chercher les $w$ tels que $w^2=Delta$. On pose $w=a+bcdot i$. On a alors le système d'équations suivant :
begin{center}
begin{tabular}{cl}
&$left{begin{array}{l}
module{w}^2=module{Delta}
w^2=Delta
end{array}right.$
$Leftrightarrow$ &$left{begin{array}{l}
a^2+b^2=sqrt{91^2+60^2}
(a^2-b^2)+2abi=91+60i
end{array}right.$
$Leftrightarrow$ &$left{begin{array}{l}
a^2+b^2=109
(a^2-b^2)=91
2ab=60
end{array}right.$
$Leftrightarrow$ &$left{begin{array}{l}
2a^2=200
2b^2=18
2ab=60
end{array}right.$
end{tabular}
end{center}
qui donne les deux solutions $w_0=10+3i$ et $w_1=-10-3i$.
Ceci fournit les deux solutions de notre équation de départ
$$z_0=frac{-(4+7i)+10+3i}2=3-2i$$ et
$$z_1=frac{-(4+7i)-10-3i}2=-7-5i$$}
item Résoudre l'équation $2iz^2+(1+5i)cdot z-1+13i=0$
defedition{E}
hide{On a : $begin{array}[t]{ccl}Delta&=&(1+5i)^2-4cdot2i cdot(-1+13i)
&=&1-25+10i+8i+104
&=&80+18i
end{array}$
On doit donc chercher les $w$ tels que $w^2=Delta$. On pose $w=a+bcdot i$. On a alors le système d'équations suivant :
begin{center}
begin{tabular}{cl}
&$left{begin{array}{l}
module{w}^2=module{Delta}
w^2=Delta
end{array}right.$
$Leftrightarrow$ &$left{begin{array}{l}
a^2+b^2=sqrt{80^2+18^2}
(a^2-b^2)+2abi=80+18i
end{array}right.$
$Leftrightarrow$ &$left{begin{array}{l}
a^2+b^2=82
(a^2-b^2)=80
2ab=18
end{array}right.$
$Leftrightarrow$ &$left{begin{array}{l}
2a^2=2
2b^2=162
2ab=18
end{array}right.$
end{tabular}
end{center}
qui donne les deux solutions $w_0=9+i$ et $w_1=-9-i$.
Ceci fournit les deux solutions de notre équation de départ
$$z_0=frac{-(1+5i)+9+i}{4i}=-1-2i$$ et
$$z_1=frac{-(1+5i)-9-i}{4i}=frac{-3+5i}2$$
}
}
end{document}
I know that I should fit some fontspec code in my hide method. The problem is I don’t know what to do although I tried to read the documentation, but I find it pretty hard to understand. I would like to use a sffamily font, keep the very same font for the math mode, but change the color of both those fonts. I managed to write for intance in Verdana in red and keep red after a page brea, but the math in the text stay in black.
Im sure there is a very easy solution which probably takes two lines of codes. If anybody has a clue he’s most welcome.
Hercule
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP