-
Notifications
You must be signed in to change notification settings - Fork 2
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
Automatic line wrap in the same indent level? #16
Comments
I'm glad you like the package! Also, thanks for the clear example. (And sorry I didn't notice the issue until now!) First, a quick tip: You might not want to put the As for the line breaking: Well, that's not really something that's directly supported at the moment, I'm afraid. I'm sure you've seen the HOWTO on having steps span multiple lines already – and it doesn't really address the issue (as it isn't automatic), but it does at least produce a result similar to what you want. That is, you could use \begin{algorithm}{Proposed method}{prop}
\begin{pseudo}
\kw{for} $i = 1, \dots, 100$ \\+
A short process, this is fine \\
A really very long long process which was proposed \\
in a paper published a lot lot years ago. \\
Manual linebreaking is fine of cource. \\
\kw{if} some condition is satisfied \\+
A really very long long process which was proposed in a paper \\*
& published a lot lot years ago... \\+
Also I want this line to be wrapped under the same indent \\*
& level... \\
I want to get\\
like this automatically
\end{pseudo}
\end{algorithm} Of course this has two distinct disadvantages: (1) It is not automatic, and (2) it leads to ragged-right text (which might not be what you want). Now, I'm sure there are ways of getting what you want. For example:
I'll look into this – it would be a good feature to have. |
The line break hijacking could perhaps be done in a manner similar to that used in the lineno package. That package does a lot of really clever stuff in the more recent versions, but we probably only need the basic mechanism, found in the original version. Essentially, it's about using |
More relevant explanations of |
I've had a look at some mechanisms, here, and it doesn't seem entirely straightforward. I'd still like to get this into the package, but I'm not sure how soon that'll be. For now, my recommended solution is to use Some musing on various options below, if you're interested. Now, if you can work with the manual line breaking, and you can set the width of your main text column manually (or you can at least find its width), you can still manage to get adjusted text. It's not super-elegant, but it works: \newlength\mywidth
\setlength\mywidth{11.5cm}
\pseudoset{
indent-mark,
preamble = {
@{}
r
>{\leavevmode\pseudosetup}
p{\mywidth}
@{}
},
}
\begin{pseudo}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat. \\+
\makebox[\mywidth - \pseudoindentlength][s]{%
At vero eos et accusam et justo duo dolores et ea rebum. Gubergren,} \\*&
no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{pseudo} This produces the following: The point is simply that the main pseudocode is set in a I could add some functionality for this, I guess, but I'm not yet 100% sure it's really useful, or the right way to go. Now, if you've got the width of the column, you could also use \begin{pseudo}
% Don't really need a \parbox at the first level …
\parbox[t]{\mywidth}{Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.}
\\+
\parbox[t]{\mywidth - \pseudoindentlength}{At vero eos et accusam et justo duo
dolores et ea rebum. Gubergren, no sea takimata sanctus est Lorem ipsum dolor
sit amet.}
\end{pseudo} This does work – however it messes with the spacing between the steps (i.e., the numbered "lines"): Getting the spacing right is probably just a matter of tweaking, so something like this could work. Another option, which would require restructuring the basic mechanisms of Using |
First, thank you for the excellent package!
I tried to write pseudocode with your package in a float environment.
My question: how to wrap lines under the same indent level in float environment?
I looked over your documentation and implementation but could not find an appropriate solution.
Here is a brief example.
Then I got a result like this:
The text was updated successfully, but these errors were encountered: