Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labels for wires #6

Open
1 task done
jonsterling opened this issue Jun 1, 2023 · 3 comments
Open
1 task done

Labels for wires #6

jonsterling opened this issue Jun 1, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@jonsterling
Copy link

jonsterling commented Jun 1, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Original problem

It would be really nice to support placing a label node on a wire, like --f--[box]--g--. I think with this feature, it would be possible for me to begin using this package.

Proposed solution

I am not certain what the most harmonious syntax for doing this would be. One tends to need a bit of flexibility in terms of where the label node is placed, how it is aligned or rotated, etc.

Alternatives considered

No response

Additional context

No response

@jonsterling jonsterling added the enhancement New feature or request label Jun 1, 2023
@paolobrasolin
Copy link
Owner

I'll jot down a few ideas.

Generally speaking, all standard TikZ techniques work:

% these are all equivalent:
\draw (A.east.1) to[red, edge node={node [blue] {f}}] (B.west.2);
\draw (A.east.1) edge [red] node [blue] {f} (B.west.2);
\draw (A.east.1) edge [red, edge label={f}] (B.west.2);
\draw (A.east.1) edge [red, "f"[blue]] (B.west.2);

So, however complicated the situation gets, one can always use plain Tikz.

That being said, the most harmonious syntax could be obtained by injecting the last technique from above into the \wires command; something along the lines of

\wires{ A = { east.1 = B.west.2[red, "f"[blue]] } }{}

It's not pretty, but for the most common usage it reduces to

\wires{
  A = { east.1 = B.west.2["f"] },
}{
  A.east.2["g"]
}

@jonsterling
Copy link
Author

@paolobrasolin Thanks! I might try the first approach... Personally my experience with cool tikz libraries is that in the end I mainly want to use the primitive (like \draw) with some useful styles attached, rather than an all-encompassing solution (like either \wires or tikzcd's matrices), because when I need to go beyond what the latter supports, it results in a lot of rewriting of code. So let me play around with the former, and I'll let you know if I think of any ideas for how such a feature might be usefully enhanced. I think already the new pgf shapes that you have defined in this library are really useful, and I probably would get a lot of mileage from just using those to start with!

@paolobrasolin
Copy link
Owner

Cool, @jonsterling! Then be careful about the anchor names. The current release only has west0, west1, east0 and east1, but i'm working on #2 which will make their count configurable and name them according to the format I used above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants