How can I get the current position within the line? Or how can I find out how much space is left until the end of line? (With the help of
\linewidth it is easy to deduct one value from the other)
Here is an example of what I want to achieve (the example is done with manual spacing).
I want to know the width of the red box (red box is inserted my me in the screenshot). After I know the length it is easy to do something like this:
I am using the algpseudocode package to write pseudocode. The package provides a
\Comment command to place comments after the lines. I want to have longer comments that span over multiple lines as shown in the screenshot.
What have I tried so far?
linegoalpackage. This worked somehow, but the value that the package determines changes (slightly) every time I compile it. It also has a strange error that the value is always wrong by a constant difference.
Following the answers here: How to get element position in LaTeX?. This worked so far that I get the absolute position, but I am unable to determine the relative position from that. If I could know the absolute x-position of the end of line I could determine the spacing, but how to do that?
Measuring everything that is positioned left of the red box manually. This works but I need to know before what will be positioned there. Using that method is cumbersome.