Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #113: Root nameservers are out of sync


comp / comp.text.tex / Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.

SubjectAuthor
* [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.Annada Behera
+- Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.Stefan Ram
+- Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.Stefan Ram
+* Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.Stefan Ram
|`* Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.Annada Behera
| `- Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.Stefan Ram
+- Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.Ulrich D i e z
`- Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.Ulrich D i e z

1
Subject: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
From: Annada Behera
Newsgroups: comp.text.tex
Organization: tilde.green
Date: Fri, 30 Aug 2024 07:59 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.quux.org!tilde.green!.POSTED.103.160.128.7!not-for-mail
From: segfault@tilde.green (Annada Behera)
Newsgroups: comp.text.tex
Subject: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF
intersections.
Date: Fri, 30 Aug 2024 13:29:14 +0530
Organization: tilde.green
Sender: segfault@tilde.green
Message-ID: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: tilde.green; posting-account="segfault@tilde.green"; posting-host="103.160.128.7";
logging-data="1942930"; mail-complaints-to="admins@tilde.green"
User-Agent: Evolution 3.52.2
View all headers

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,

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

% Drawing the dots
\fill[name intersections={of=line and sine, name=i, total=\t}, black]
\foreach \s in {1,...,\t} {(i-\s) circle (2pt)};

\end{tikzpicture}\end{document}

Now this code works as expected. But I also wanted to draw dashed lines from
the intersections to each axes.

% Axes
\draw [<->](-6.28, 0) -- (6.28, 0);
\draw [<->](0, -6.28) -- (0, 6.28);

% Mark intersection points and draw dashed lines
\foreach \n in {1,...,\t} {
\path ({i-\n}) coordinate (i\n); % <--- Error Here
\fill[black] (i\n) circle (2pt);
\draw[dashed] (i\n) -- (i\n |- 0,0);
\draw[dashed] (i\n) -- (0,0 -| i\n);
}

In this part, pdflatex (my distro is TeX Live 2024) throws an error what
I don't understand,

! Undefined control sequence.
\UseTextAccent ...p \@firstofone \let \@curr@enc
\cf@encoding \@use@text@en...
l.28 }

What is undefined? I am pretty sure the name=i in \fill command populates
the namespace with i-1, 1-2 and 1-3, because \fill has drawn them. I
have even tried to help the parser with extra braces, {i-\n} and {i\n}
but that also doesn't help. Anybody know the reason why I get the error
and how to fix them?

Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
From: Stefan Ram
Newsgroups: comp.text.tex
Organization: Stefan Ram
Date: Fri, 30 Aug 2024 12:20 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.text.tex
Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
Date: 30 Aug 2024 12:20:12 GMT
Organization: Stefan Ram
Lines: 69
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <loop-20240830131903@ram.dialup.fu-berlin.de>
References: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de Mi9fEbTS/YBp3A3ZoFHg/gebUfTqOiw3z0W9tGXoJYYXG/
Cancel-Lock: sha1:JazfcuYkIWpeCvZZ8rWzyEZuC8k= sha256:Mdw10bTvmNr/3sW7snGYbJm7eu2dVobEvkUuUZNscOg=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Annada Behera <segfault@tilde.green> wrote or quoted:
> \foreach \n in {1,...,\t} {
> \path ({i-\n}) coordinate (i\n); % <--- Error Here
> \fill[black] (i\n) circle (2pt);
> \draw[dashed] (i\n) -- (i\n |- 0,0);
> \draw[dashed] (i\n) -- (0,0 -| i\n);
> }

I'm about as familiar with LaTeX as I am with surfing Pipeline
- which is to say, not at all. And this tikz thing? Totally
off my radar. But after messing around like a bear in a honey
factory, I stumbled onto something. Turns out, if you unravel
that last loop and use the following code, it's all gravy here.

\path ({i-1}) coordinate (i1);
\fill[black] (i1) circle (2pt);
\draw[dashed] (i1) -- (i1 |- 0,0);
\draw[dashed] (i1) -- (0,0 -| i1);
\path ({i-2}) coordinate (i2);
\fill[black] (i2) circle (2pt);
\draw[dashed] (i2) -- (i2 |- 0,0);
\draw[dashed] (i2) -- (0,0 -| i2);
\path ({i-3}) coordinate (i3);
\fill[black] (i3) circle (2pt);
\draw[dashed] (i3) -- (i3 |- 0,0);
\draw[dashed] (i3) -- (0,0 -| i3);
\path ({i-4}) coordinate (i4);
\fill[black] (i4) circle (2pt);
\draw[dashed] (i4) -- (i4 |- 0,0);
\draw[dashed] (i4) -- (0,0 -| i4);

| /H H
| :$ .;XM
| =$ +%$@=
| =$ .+$//H:
| =$ .+$+ +H=
| =$ ,+%+ XH
| =$ ,+$/ /H$
| =$ .+%; /XX=
| =$ .--,+HX$/+$X$:
| =$ ;$X$%X@#M+++/:
| =$ %HX/.-+%;-
| =$ :HX, ,+%/ ;: .
| =$ $H: -%%; ;=
| =$ HX -%%; ;=
| =$ .H$-%%; ;=
| :$ HX+$; ;=
| %@H+: ;=
|;/::::::::::::::::;:::::::::::::;:-X#@+:=;:::::::::::%+:::::::::::::::;
|X/---------------=%------------,,/X#M ---------------------------------
|$, / :%$M;/
|$- / ;%%%H:-$
|$- / ;%%-/H= :$
|$- / ;%%- $H, =$
|$- + ;%%- =HX =$
|$- .+ ;%+, ,XH/ =$
|$- ;;%+=-+XX% =$
|$- .;%%%$@#@X%$$%: =$
|$- :XX$;:%$%: =$
|$- -XH/ ;%+, =$
|$- +H+ /$+, =$
|$- XH +%+, =$
|$- H$ /$+, =$
|$-.H$/$+. =$
|+,@H%+. =$
|@#H;. :$
|##;/+++++++++++++++++++++++++++++++X@++++++++++++++++++++++++++++++++++

Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
From: Stefan Ram
Newsgroups: comp.text.tex
Organization: Stefan Ram
Date: Fri, 30 Aug 2024 22:26 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.text.tex
Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
Date: 30 Aug 2024 22:26:28 GMT
Organization: Stefan Ram
Lines: 24
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <loop-20240830232543@ram.dialup.fu-berlin.de>
References: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de k10TcEbdv18X3EW5S2q0eQb9bqH7Rdjo3+IRzlgQGjmshj
Cancel-Lock: sha1:atf0croSze6vFxyP6HRDX8VKC2A= sha256:olxpHZ7gbWeGKGK8cwlvs0gjsY0u8PdbD040PvqVOag=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Annada Behera <segfault@tilde.green> wrote or quoted:
>% Mark intersection points and draw dashed lines
>\foreach \n in {1,...,\t} {
> \path ({i-\n}) coordinate (i\n); % <--- Error Here
> \fill[black] (i\n) circle (2pt);
> \draw[dashed] (i\n) -- (i\n |- 0,0);
> \draw[dashed] (i\n) -- (0,0 -| i\n);
>}

Plain TeX to the rescue! What also works here is:

% Mark intersection points and draw dashed lines
\newcount\n
\n=1
\loop
\path ({i-\the\n}) coordinate (i\the\n);
\fill[black] (i\the\n) circle (2pt);
\draw[dashed] (i\the\n) -- (i\the\n |- 0,0);
\draw[dashed] (i\the\n) -- (0,0 -| i\the\n);
\advance\n by 1
\ifnum\n<5
\repeat

Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
From: Stefan Ram
Newsgroups: comp.text.tex
Organization: Stefan Ram
Date: Sat, 31 Aug 2024 18:14 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.text.tex
Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
Date: 31 Aug 2024 18:14:25 GMT
Organization: Stefan Ram
Lines: 14
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <t-20240831191358@ram.dialup.fu-berlin.de>
References: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 9Ah9rGMsFUXhPuSmQticDQ01pw7qERv2+3zbG6/2SURNw0
Cancel-Lock: sha1:YCF7Zt3XVscC0sBGwC5B2wD33Q4= sha256:WL3UOVYZzoGImvRtCGSXCuaLTZaBddBwnwZSSgUtzPw=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Annada Behera <segfault@tilde.green> wrote or quoted:
>% Mark intersection points and draw dashed lines
>\foreach \n in {1,...,\t} {
.. . .
>What is undefined?

Looks like "\t" is on the fritz or not pulling its weight,
since the loop seems to be cruising when we swap "\t" for "4":

\foreach \n in {1,...,4} {

. That error message was probably about as clear as LA smog.

Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
From: Annada Behera
Newsgroups: comp.text.tex
Organization: tilde.green
Date: Sun, 1 Sep 2024 07:52 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!panix!weretis.net!feeder9.news.weretis.net!news.quux.org!tilde.green!.POSTED.103.160.128.7!not-for-mail
From: segfault@tilde.green (Annada Behera)
Newsgroups: comp.text.tex
Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF
intersections.
Date: Sun, 01 Sep 2024 13:22:58 +0530
Organization: tilde.green
Sender: segfault@tilde.green
Message-ID: <3e9a663629f7c14eb87d890bc0adf87218a28967.camel@tilde.green>
References: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green>
<t-20240831191358@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: tilde.green; posting-account="segfault@tilde.green"; posting-host="103.160.128.7";
logging-data="3878707"; mail-complaints-to="admins@tilde.green"
User-Agent: Evolution 3.52.2
In-Reply-To: <t-20240831191358@ram.dialup.fu-berlin.de>
View all headers

On Sat, 2024-08-31 at 18:14 +0000, Stefan Ram wrote:
> Annada Behera <segfault@tilde.green> wrote or quoted:
> > % Mark intersection points and draw dashed lines
> > \foreach \n in {1,...,\t} {
> . . .
> > What is undefined?
>
>   Looks like "\t" is on the fritz or not pulling its weight,
>   since the loop seems to be cruising when we swap "\t" for "4":
>
> \foreach \n in {1,...,4} {
>
>   . That error message was probably about as clear as LA smog.

In this line, \t is definitely "pulling its weight,"

\fill[name intersections={of=line and sine, name=i, total=\t}, black]
\foreach \s in {1,...,\t} {(i-\s) circle (2pt)};

It's just looks like \t's scope is limited to the commands where it is defined.
Don't know whether this is expected behavior or a bug.

Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
From: Stefan Ram
Newsgroups: comp.text.tex
Organization: Stefan Ram
Date: Sun, 1 Sep 2024 15:13 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.text.tex
Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
Date: 1 Sep 2024 15:13:46 GMT
Organization: Stefan Ram
Lines: 34
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <semicolon-20240901155334@ram.dialup.fu-berlin.de>
References: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green> <t-20240831191358@ram.dialup.fu-berlin.de> <3e9a663629f7c14eb87d890bc0adf87218a28967.camel@tilde.green>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.text.tex
Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
Date: 1 Sep 2024 15:13:46 GMT
Organization: Stefan Ram
Lines: 34
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <semicolon-20240901155334@ram.dialup.fu-berlin.de>
References: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green> <t-20240831191358@ram.dialup.fu-berlin.de> <3e9a663629f7c14eb87d890bc0adf87218a28967.camel@tilde.green>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de pYq3+l+P/4Z4P7/vIQMBQgyNEIBZDX368S5BiP15MxM420
Cancel-Lock: sha1:09ID1zatgV0gHh01wPan5q/H5Lo= sha256:D/ijFAaOe/LTGW97RfoZj6J6gisZWEgDuSpSN1LuwD0=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de pYq3+l+P/4Z4P7/vIQMBQgyNEIBZDX368S5BiP15MxM420
Cancel-Lock: sha1:09ID1zatgV0gHh01wPan5q/H5Lo= sha256:D/ijFAaOe/LTGW97RfoZj6J6gisZWEgDuSpSN1LuwD0=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Annada Behera <segfault@tilde.green> wrote or quoted:
>Don't know whether this is expected behavior or a bug.

The TikZ & PGF manual (for Version 3.1.5b) has got this entry
"/tikz/intersection/total=<macro>" in the "13.3.2 Intersections
of Arbitrary Paths" section. It's got this example where
the "\foreach \s in {1,...,\t}" is all indented and stuff.

|\usetikzlibrary {intersections}
|\begin{tikzpicture}
| \clip (-2,-2) rectangle (2,2);
| \draw [name path=curve 1] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1);
| \draw [name path=curve 2] (-1,-2) .. controls (-1,8) and (1,-8) .. (1,2);
| | \fill [name intersections={of=curve 1 and curve 2, name=i, total=\t}]
| [red, opacity=0.5, every node/.style={above left, black, opacity=1}]
| \foreach \s in {1,...,\t}{(i-\s) circle (2pt) node {\footnotesize\s}};
|\end{tikzpicture}
| from "TikZ & PGF" "Manual for Version 3.1.5b".

If you drop a semicolon in front of the "\foreach" (right after
"opacity=1}]"), it's going to wig out on you with that error message.

Well, "\fill" is shorthand for "\path[fill]", and the 411 on
"\path" syntax is dropped in "14 Syntax for Path Specifications",
which lays it down like this:

|\path<specification>;

. So, there's that semicolon hanging ten, but I'm not stoked on where
its implications for the scope of "name intersections" is posted up.

Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
From: Ulrich D i e z
Newsgroups: comp.text.tex
Date: Mon, 2 Sep 2024 00:52 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: ud.usenetcorrespondence@web.de (Ulrich D i e z)
Newsgroups: comp.text.tex
Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF
intersections.
Date: Mon, 2 Sep 2024 02:52:46 +0200
Message-ID: <vb328v$20a9j$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 00:52:48 -0000 (UTC)
Injection-Info: solani.org;
logging-data="2107699"; 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:Yhq9xNrdjqsVmfhJQ2hwohVLE78=
Content-Language: en-US
X-User-ID: eJwFwQkBACAIBLBK8h0QR0D6R3AzAaFdYVBb28g4Uv2YQw6PpgSvI7as8DDbE0WXm1xu7vsP7BFB
In-Reply-To: <10c8b515e70ecda9ad95fc1529ff3b102da812e4.camel@tilde.green>
View all headers

Annada Behera wrote:

> \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)});
>
> % Drawing the dots
> \fill[name intersections={of=line and sine, name=i, total=\t}, black]
> \foreach \s in {1,...,\t} {(i-\s) circle (2pt)};
>
> \end{tikzpicture}\end{document}
>
> Now this code works as expected. But I also wanted to draw dashed lines from
> the intersections to each axes.
>
> % Axes
> \draw [<->](-6.28, 0) -- (6.28, 0);
> \draw [<->](0, -6.28) -- (0, 6.28);
>
> % Mark intersection points and draw dashed lines
> \foreach \n in {1,...,\t} {
> \path ({i-\n}) coordinate (i\n); % <--- Error Here
> \fill[black] (i\n) circle (2pt);
> \draw[dashed] (i\n) -- (i\n |- 0,0);
> \draw[dashed] (i\n) -- (0,0 -| i\n);
> }
>
> In this part, pdflatex (my distro is TeX Live 2024) throws an error what
> I don't understand,
>
> ! Undefined control sequence.
> \UseTextAccent ...p \@firstofone \let \@curr@enc
> \cf@encoding \@use@text@en...
> l.28 }
>
> What is undefined?

When you say

\errorcontextlines=10000
\documentclass{...

, the error-message is:

! Undefined control sequence.
\UseTextAccent ...p \@firstofone \let \@curr@enc
\cf@encoding
\@use@text@en...

\?-cmd ...sname \csname ?\string #1\endcsname \fi
\csname \cf@encoding
\stri...

\pgffor@dots@charcheck ...@dots@charcheck@temp {#1
}\expandafter
\expandafter...

\pgffor@dots@value@process ...value \pgffor@@stop

\ifpgffor@alphabeticsequen...

\pgffor@dotsscanend ...@process {\pgffor@dotsend }

\pgffor@dots@value@process...

\pgffor@values ->1,...,\t ,
\pgffor@stop ,
l.27 }

and you see that \t in "\foreach \n in {1,...,\t} {...}" is undefined,

The problem is that the macro \t comes into being while a TikZ-path is
evaluated - \fill is a macro which expands to "\path..." - while TikZ
does not do control-sequence-evaluation/macro-expansion as usual while
parsing/evaluating/carrying out a TikZ-path-directive.

So you face the nice problem that \t being defined is restricted to the
scope of that TikZ-path-directive while inside TikZ-path-directives you
cannot easily use macros/control-sequences as directives for saving \t
away as a global macro which is available outside the scope of the
\fill-path-directive also.

As \t denotes a natural number, you can work around this problem by as a
component of the TikkZ-path-directive specifying a TikZ-coordinate where
one component (either the X-component or the Y-component) comes from \t,
using the measurement-unit sp (scaled point) and later retrieving that
component of the TikZ-coordinate and using it with \number, hereby
taking into account that using a TeX-\dimen or a TeX-\skip or a
LaTeX-length with \number directly yields the numerical value which
belongs to the quantity in question when it is expressed as a multiple
of the measurement-unit sp (scaled point):

%\errorcontextlines=10000
\documentclass{standalone}
\usepackage{tikz, amsmath}
\usetikzlibrary{intersections}

\newlength\scratchlength

\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 \t for saving a coordinate so that
% \t can later be retrieved outside the scope of the \fill-path
% as well:
\fill [name intersections={of=line and sine, name=i, total=\t},
black]
\foreach \s in {1,...,\t} {(i-\s) circle (2pt)}
% Before ending with a semicolon (;) the path-specifica-
% tion started via \fill, let's save total/\t as the
% y-value of a TikZ-coordinate whose name is "total";
% specify the unit sp (scaled point) as all lengths in
% TeX internally are calculated/rounded to be integer
% multiples of 1sp; thus when specifying sp you don't get
% rounding-errors when later retrieving the value:
coordinate (total) at (0pt, \t sp);

% Extraxt to \scratchlength the y-coordinate of the pgfpoint
% which forms the center-anchor of the coordinate-node whose
% name is "total" :
\pgfextracty{\scratchlength}{\pgfpointanchor{total}{center}}%
% When you use a TeX-\dimen or TeX-\skip/LaTeX-length with
% \number directly, you get the numerical value which belongs
% to the (unstretched and unshrinked) quantity in question
% when it is expressed as a multiple of the measurement-unit
% sp(scaled point).
% So we are lucky as in the begin dimensions for coordinates
% were provided with measurement unit sp:
\edef\t{\number\scratchlength}%
% Now we have \t defined outside the scope of the \fill-path
% and can use it in next \foreach-loop.
%\show\t

% Axes
\draw [<->](-6.28, 0) -- (6.28, 0);
\draw [<->](0, -6.28) -- (0, 6.28);

% Mark intersection points and draw dashed lines
\foreach \n in {1,...,\t} {
\path ({i-\n}) coordinate (i\n); % <--- Error Here
\fill[black] (i\n) circle (2pt);
\draw[dashed] (i\n) -- (i\n |- 0,0);
\draw[dashed] (i\n) -- (0,0 -| i\n);
}

\end{tikzpicture}

\end{document}

Sincerely

Ulrich

Subject: Re: [LaTeX][PGF/TikZ] Undefined control sequence error for PGF intersections.
From: Ulrich D i e z
Newsgroups: comp.text.tex
Date: Mon, 2 Sep 2024 04:25 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: ud.usenetcorrespondence@web.de (Ulrich D i e z)
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
View all headers

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

1

rocksolid light 0.9.8
clearnet tor