20 Jan 2024 |
Manis | Another problem popped up, though. If my \pgfplotstabletypeset is inside a command into which I want to inject additional pgfkeys, do I need to treat them in a special way?
This does not work:
\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotstableread[col sep=comma,header=false]{
foo,42
}\mytable
\newcommand{\plottable}[2][]{
\pgfplotstabletypeset[
every head row/.style={output empty row},
columns/0/.append style={
string type,
},#1
]{#2}
}
\begin{document}
\plottable[
columns/0/.append style={
/pgfplots/table/string replace*={foo}{bar}
}
]{\mytable}
\end{document}
| 11:11:59 |
Manis | * Another problem popped up, though. If my \pgfplotstabletypeset is inside a command into which I want to inject additional pgfkeys, do I need to treat them in a special way?
This does not work:
\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotstableread[col sep=comma,header=false]{
foo,42
}\mytable
\newcommand{\plottable}[2][]{
\pgfplotstabletypeset[
every head row/.style={output empty row},
columns/0/.append style={
string type
},#1
]{#2}
}
\begin{document}
\plottable[
columns/0/.append style={
/pgfplots/table/string replace*={foo}{bar}
}
]{\mytable}
\end{document}
| 11:12:12 |
Manis | Ah, I must not have any newlines in the optional argument to \plottable . But why are they ignored when directly passed to the \pgf... commands but not when they "go through" #1 ? | 11:15:53 |
marei | In reply to @manis:matrix.org If I want to string replace*={ }{\,} , do I need to expand \, first? If you typeset the table/ content it would be expanded later. In the cell itself it's not. and that's also what I would expect. To get the thinspace directly you would have to change the category code otherwhise it's just a space. | 15:18:46 |
marei | In reply to @manis:matrix.org Ah, I must not have any newlines in the optional argument to \plottable . But why are they ignored when directly passed to the \pgf... commands but not when they "go through" #1 ? and that's also an issue with spaces… as spaces are preserved in that setup. so
| 15:19:42 |
marei | In reply to @manis:matrix.org Ah, I must not have any newlines in the optional argument to \plottable . But why are they ignored when directly passed to the \pgf... commands but not when they "go through" #1 ? * and that's also an issue with spaces… as spaces are preserved in that setup. so
\plottable[
columns/0/.append style={
/pgfplots/table/string replace*={foo}{bar}
}%
]{\mytable}
would work, or
\plottable[
columns/0/.append style={
/pgfplots/table/string replace*={foo}{bar}
}]{\mytable}
| 15:21:12 |
Manis | I need to read up on the TeX parser. OK, so if I have a newline at the end of the optional argument to \plottable and a newline after the #1 inside \plottable it breaks. If I remove _either_ it works. | 18:56:12 |
7 Feb 2024 |
| Bean joined the room. | 23:07:49 |
| Bean changed their display name from Richard A to Bean. | 23:11:49 |
| Bean set a profile picture. | 23:11:52 |
1 Mar 2024 |
| Malin joined the room. | 17:48:28 |
3 Mar 2024 |
| Brodulf joined the room. | 09:13:38 |
31 Mar 2024 |
zebrag | I want to cut the plane in two parts through a straight line, then put a point in one of the half-plane, the consider a circle centered on this point with radius greater than the distance of the point to the straight line, and actually draw only the arc/part of the circle, that is on the half plane where the point (center of the circle) is not.
What are the best options to do that? | 21:45:32 |
zebrag | * I want to cut the plane in two parts through a straight line, then put a point in one of the half-plane, then consider a circle centered on this point with radius greater than the distance of the point to the straight line, and actually draw only the arc/part of the circle, that is on the half plane where the point (center of the circle) is not.
What are the best options to do that? | 21:46:40 |
2 Apr 2024 |
zebrag | Btw, this is what I came with:
\documentclass[tikz,border=2mm]{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\usepackage{xfp}
% Define the new command for sign-related angle adjustment
\newcommand{\adjustangle}[1]{%
\fpeval{(#1) < 0 ? 180 : 0}%
}
\begin{document}
\begin{tikzpicture}
% Define the line as a path to be reused
\coordinate (A) at (-4,0);
\coordinate (B) at (4,1);
\path[name path=line] (A) -- (B);
% Place the point
\coordinate (P) at (1,1.5);
% Circle with radius greater than distance to the line, choose arbitrary for this example
\def\radius{2cm}
% Define the circle path
\path[name path=circle] (P) circle (\radius);
% Calculate intersections
\path[name intersections={of=circle and line,by={C,D}}];
% Draw the straight line
\draw (A) -- (B);
% Mark the point
\fill (P) circle (2pt) node[above] {$P$};
\fill (C) circle (2pt) node[above] {$C$};
\fill (D) circle (2pt) node[above] {$D$};
% Draw the part of the circle on the other half plane
\draw[very thick, blue] let \p1=(C), \p2=(D), \p3=(P) in (C)
arc[start angle={atan((\y1-\y3)/(\x1-\x3))-\adjustangle{\x1-\x3}},
end angle={atan((\y2-\y3)/(\x2-\x3))-\adjustangle{\x2-\x3}},
radius=\radius];
\end{tikzpicture}
\end{document}
| 22:47:49 |
6 Apr 2024 |
zebrag | I'm trying to have something like that working:
\documentclass{article}
\usepackage{tikz}
\newcommand{\adjustangle}[1]{%
\pgfmathparse{ifthenelse(#1 < 0, 180, 0)}
\pgfmathresult
}
\begin{document}
\begin{tikzpicture}
\draw
(0,1) arc[start angle={45-\adjustangle{45}},
end angle={60},
radius=1];
\end{tikzpicture}
\end{document}
| 10:18:33 |
zebrag | But whichever way I put it I always have something like that:
\pgfmath@catcodes ...`\|=12 \catcode `\&=12 \let "
\pgfmath@char@quote
| 10:19:22 |
zebrag | Is there no other way than inlining? | 10:27:20 |
13 Apr 2024 |
muzimuzhi | What | 05:29:42 |
muzimuzhi | * What's "inlining"? | 05:29:52 |
muzimuzhi | You can declare new pgfmath functions through /pgf/declare function key:
\tikzset{
declare function={adjustangle(\a)=ifthenelse(\a < 0, 180, 0);}
}
| 05:34:52 |
muzimuzhi | * You can declare new pgfmath functions through /pgf/declare function key:
\tikzset{
declare function={adjustangle(\a)=ifthenelse(\a < 0, 180, 0);}
}
It's slower than \pgfmathdeclarefunction , but easier to use.
| 05:35:46 |
muzimuzhi | Full example
\documentclass{article}
\usepackage{tikz}
\tikzset{
declare function={adjustangle(\a)=ifthenelse(\a < 0, 180, 0);}
}
\begin{document}
\begin{tikzpicture}
\draw
(0,1) arc[start angle={45-adjustangle{45}},
end angle={60},
radius=1];
\end{tikzpicture}
\end{document}
| 05:37:09 |
muzimuzhi | In reply to @inkbottle:matrix.org I want to cut the plane in two parts through a straight line, then put a point in one of the half-plane, then consider a circle centered on this point with radius greater than the distance of the point to the straight line, and actually draw only the arc/part of the circle, that is on the half plane where the point (center of the circle) is not. What are the best options to do that? Have a look at tkz-euclide package? https://ctan.org/pkg/tkz-euclide | 05:39:19 |
zebrag | Hi, tx, looking into that asap | 11:19:19 |
zebrag | In reply to @muzzi:matrix.org What's "inlining"? In this context it would be inserting the body of the macro everywhere the macro should be called/expanded, in other words performing the macro expansion by hand. | 11:21:28 |
29 Apr 2024 |
| Nei joined the room. | 21:34:48 |
5 May 2024 |
| ZM Berber joined the room. | 19:26:30 |
12 May 2024 |
| sourcecodedeleted joined the room. | 18:24:15 |
sourcecodedeleted | Good evening everyone | 18:24:38 |