Deutsch English Français Italiano |
<vb3eoe$20hc7$1@solani.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Ulrich D i e z <ud.usenetcorrespondence@web.de> Newsgroups: comp.text.tex Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections. Date: Mon, 2 Sep 2024 06:25:49 +0200 Message-ID: <vb3eoe$20hc7$1@solani.org> References: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Mon, 2 Sep 2024 04:25:50 -0000 (UTC) Injection-Info: solani.org; logging-data="2114951"; mail-complaints-to="abuse@news.solani.org" User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Cancel-Lock: sha1:34vSRO7MwNnDTdFQ33F878Y7QyA= In-Reply-To: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green> X-User-ID: eJwFwYEBwCAIA7CX0EEL5ziw/59gEh8Wmo6Ah0Lyzq2JnxOq01X7kGaAxssmycblMtpc5n4liRDx Content-Language: de-DE Bytes: 2388 Lines: 50 Annada Behera wrote: > Consider this minimal working example. I have two functions, f(x) = x > and g(x) = x+sin(x). I want to draw them with PGF and at the intersection > points, I want put black dots. Here is the TikZ code, I just realized that inside TikZ-paths you can use \pgfextra{...} for having LaTeX carry out arbitrary LaTeX code. You can use this for making \t a global macro: %\errorcontextlines=10000 \documentclass{standalone} \usepackage{tikz, amsmath} \usetikzlibrary{intersections} \begin{document} \begin{tikzpicture} % Plots \draw[very thick, smooth, samples=20, domain=-6.28:6.28] [red, name path=line] (0,0) plot (\x, \x); \draw[very thick, smooth, samples=20, domain=-6.28:6.28] [blue, name path=sine] (0,0) plot (\x, {\x + sin(\x r)}); % Draw the dots and use \pgfextra for globally saving \t: \fill [name intersections={of=line and sine, name=i, total=\t}, fill=green, draw=black, thin] foreach \n in {1,...,\t} {(i-\n) circle (2pt)} \pgfextra{\global\let\t\t}; % Draw dashed lines \foreach \n in {1,...,\t} { \draw[dashed] ({i-\n}) -- (0,0 -| {i-\n}); } % Axes \draw [<->](-6.28, 0) -- (6.28, 0); \draw [<->](0, -6.28) -- (0, 6.28); \end{tikzpicture} \end{document} Sincerely Ulrich