3

I'm currently working on a LaTeX document where I use TikZ along with the tkz-fct package to draw mathematical functions. However, I'm facing an issue where I'm unable to assign colors to the curves \mathcal{C}_{f} and \mathcal{C}_{g}.

Here's the relevant code snippet:

\documentclass{standalone}
\usepackage{tkz-fct}

\begin{document} \begin{tikzpicture}[gridded] \tkzInit[xmin=-4,xmax=4,ymin=-4,ymax=4] \tkzAxeX \tkzAxeY \tkzFct[domain=-4:4,samples=800,draw=blue,thick]{exp(x)} \tkzText(2,4){($\mathcal{C}{\exp}$)} \tkzFct[domain=0.01:4,samples=800,draw=red,thick]{log(x)} \tkzText(4,2){($\mathcal{C}{\ln}$)} \end{tikzpicture} \end{document}

enter image description here

It seems that the color settings for \mathcal{C}_{f} and \mathcal{C}_{g} are not taking effect, and both curves appear in default colors.

Can someone please help me understand what might be causing this issue and how can I correctly assign colors to these curves?

egreg
  • 1,121,712
Educ
  • 4,362

1 Answers1

5

See example in ch 5.1 Ajouter un label in the manual. Text color seems to be assigned as color=<color> .

The labels are colored:

enter image description here

\documentclass{standalone}
\usepackage{tkz-fct}

\begin{document} \begin{tikzpicture}[gridded] \tkzInit[xmin=-4,xmax=4,ymin=-4,ymax=4] \tkzAxeX \tkzAxeY \tkzFct[domain=-4:4,samples=800,draw=blue,color=brown,thick]{exp(x)} \tkzText(2,4){($\mathcal{C}{\exp}$)} \tkzFct[domain=0.01:4,samples=800,draw=red,color=red,thick]{log(x)} \tkzText(4,2){($\mathcal{C}{\ln}$)} \end{tikzpicture} \end{document}

BTW, probably because it's built on Tikz, setting an option with \tkzText seems to work, too:

 \tkzFct[domain=0.01:4,samples=800,draw=red,thick]{log(x)}
    \tkzText[teal](4,2){($\mathcal{C}_{\ln}$)}

enter image description here

For reference, relating to Alain's comment, these are the .gnuplot files Texmaker/pdflatex created:

set table "tkzFctGrid.tkzfonct.table"; set format "%.5f"
set samples 200.0; plot [x=-5.000000000000000000:5.000000000000000000] (((-x**2-2*x+3))-0)/1
set table "tkz-fct-colors.tkzfonct.table"; set format "%.5f"
set samples 800.0; plot [x=0.010000000000000000:4.000000000000000000] ((log(x))-0)/1
egreg
  • 1,121,712
MS-SPO
  • 11,519
  • please, give me the whole code ? – Educ Jan 21 '24 at 21:37
  • It‘s there. Just move to 3rd line from the end and put an option of your choice. – MS-SPO Jan 21 '24 at 21:51
  • "I'm experiencing an issue where the curves are missing in my LaTeX document. I am using Windows 10 with TeXstudio as my LaTeX editor. I had previously used Overleaf without any problems before attempting to compile the document on my PC." – Educ Jan 21 '24 at 21:54
  • Do you have gnuplot installed? I haven't, so the curves are missing, and there was a hint during compile. Is that your remark? – MS-SPO Jan 22 '24 at 03:40
  • 1
    @Educ If the curves are not displayed, there are several possible causes. The first is that gnuplot is not installed. The second is that gnuplot is installed but not found. Finally, you need to authorize the system to launch an external program using the option --shell-escape option. All this can be found on the WEB and is specific to the system, editor, etc. – Alain Matthes Jan 22 '24 at 07:21
  • 1
    @Educ To point you in the right direction, you need to check the files produced. If your file is named test, then if everything's working properly you'll get a test.tkzfonct.gnuplot file and a test.tkzfonct.table file. The first is the command sent by TikZ to gnuplot (function, domain, number of points). The second, if gnuplot is found, is the table created by gnuplot and sent to TikZ(fct). If the files are missing, open test.log and there should be \write18 enabled. in the first few lines. Type gnuplot in the search box! There are lots of answers. – Alain Matthes Jan 22 '24 at 07:30
  • 2
    @AlainMatthes Thank you I solved the issue see here https://tex.stackexchange.com/questions/707629/missing-curves-in-latex-document-and-gnuplot-installation-issue/707642#707642 – Educ Jan 22 '24 at 08:45
  • 1
    @MS-SPO I took the liberty of editing in order to add the curves. – egreg Jan 22 '24 at 09:57
  • @egreg, thanks: great improvement :) – MS-SPO Jan 22 '24 at 10:02