Before I start, I just wanted to say this is an exceptionally well-done package and I have been having a great time seeing what old figures I have can be converted. Also, if this issue has already come up and i missed it, sorry about that.
Now, I was looking at one old Tikz plot a colleague had made, seeing if it could be converted to Typst and Cetz, and it had the nice feature where text for labeling planes could be rendered as if the text was printed on the plane; that is, with rotation and skew. A minimal example is with:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{3d,perspective}
\begin{document}
\begin{tikzpicture}[rotate around y=-30,rotate around z=-20]
\begin{scope}[canvas is xz plane at y=0]
% plane
\draw[cyan,fill=cyan!5] (-4,-3) rectangle (4,3);
% label
\node[cyan,anchor=south,rotate=90,xscale=-1,transform shape] at (4,1.5) {plane label};
\end{scope}
\end{tikzpicture}
\end{document}
which renders as
tikz-plane.pdf
As I understand it, Cetz so far fundamentally can't do this due to how the content function works, namely:
"Positions Typst content in the canvas. Note that the content itself is not transformed only its position is."
The closest I can get is with something like:
#import "@preview/cetz:0.5.2"
#import "@preview/lilaq:0.6.0" as lq
#set page(
width: auto,
height: auto,
margin: 1mm
)
#cetz.canvas({
import cetz.draw: *
import cetz.vector: *
ortho(x: -35.264deg, y: 45deg, z: 0, {
group({
rotate(x: 90deg)
rect(
(-5, -5),
(5, 5),
fill: lq.color.map.petroff10.at(8).transparentize(50%),
stroke: lq.color.map.petroff10.at(8),
)
// Invisible line to represent one of the edges of the plane
line(
(-5, -4, 0),
(5, -4, 0),
stroke: lq.color.map.petroff10.at(8),
name: "plane-edge",
)
// Edge label
content(
("plane-edge.start", 40%, "plane-edge.end"),
angle: "plane-edge.end",
padding: 0.,
anchor: "south",
[plane]
)
})
})
})
which renders as
As a weird sidenote, when trying to get the label parallel to the plane edge, placing it at 50% didn't have the text parallel, but instead at an angle. Approximately 40% is where it looks roughly parallel. I couldn't say why.
Digressing, despite the text being parallel, it doesn't match the Tikz behavior where the text looks like its actually printed on the plane, again due to how the content function works.
I wanted to see if this is something that could be handled in future versions of Typst/Cetz, or if this is a fundamental limitation? It's of course not necessary, but it's a nice way to render labels when handling 3D geometry, so it'd be a shame if this is infeasible. Thanks again for a great package!
Before I start, I just wanted to say this is an exceptionally well-done package and I have been having a great time seeing what old figures I have can be converted. Also, if this issue has already come up and i missed it, sorry about that.
Now, I was looking at one old Tikz plot a colleague had made, seeing if it could be converted to Typst and Cetz, and it had the nice feature where text for labeling planes could be rendered as if the text was printed on the plane; that is, with rotation and skew. A minimal example is with:
which renders as
tikz-plane.pdf
As I understand it, Cetz so far fundamentally can't do this due to how the content function works, namely:
"Positions Typst content in the canvas. Note that the content itself is not transformed only its position is."
The closest I can get is with something like:
which renders as
As a weird sidenote, when trying to get the label parallel to the plane edge, placing it at 50% didn't have the text parallel, but instead at an angle. Approximately 40% is where it looks roughly parallel. I couldn't say why.
Digressing, despite the text being parallel, it doesn't match the Tikz behavior where the text looks like its actually printed on the plane, again due to how the content function works.
I wanted to see if this is something that could be handled in future versions of Typst/Cetz, or if this is a fundamental limitation? It's of course not necessary, but it's a nice way to render labels when handling 3D geometry, so it'd be a shame if this is infeasible. Thanks again for a great package!