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

algpseudocode \Return #25

Open
durandg12 opened this issue Jul 4, 2024 · 8 comments
Open

algpseudocode \Return #25

durandg12 opened this issue Jul 4, 2024 · 8 comments
Assignees

Comments

@durandg12
Copy link

In LaTeX when using algpseudocode, \Return has to be preceded by a \State command, or it won't appear on a new line. Problem is, this insert a blank line in html rendering.

So either I get the html render proper, without a blank line, but the \Return statement does not appear on a newline in pdf render:
Capture d’écran 2024-07-04 à 18 06 34
either I get it right in pdf but with a blank line in html :
Capture d’écran 2024-07-04 à 18 04 54

@jchiquet
Copy link
Member

Thanks,

We will update asap the pseudocode extension, hoping it will solve the problem.

@fradav
Copy link
Contributor

fradav commented Oct 16, 2024

I updated the extension, is the problem still there?

@durandg12
Copy link
Author

To test and compare the pdf output with the html output, I will have to also correct the tikz sections of my code (because of #24) before running it again

@durandg12
Copy link
Author

Hello @fradav, yes the problem is still there

@durandg12
Copy link
Author

In the meantime, what is the policy of Computo? Should I favor the HTML output (no blank line in HTML, no new line in PDF) or the reverse?

@fradav
Copy link
Contributor

fradav commented Dec 18, 2024

Sorry for the late answer.

I’ll let the editor in chief @jchiquet answer on the policy question.
In the meantime, the general method to handle this sort of discrepancies in multiple format outputs is to make the "correct" code for each format and make each part conditional to their respective format.

https://quarto.org/docs/authoring/conditional.html

::: {.content-visible when-format="html"}

Will only appear in HTML.

:::

::: {.content-hidden when-format="html"}

Will not appear in HTML.

:::

(as a separate issue, we should have this documented)

@durandg12
Copy link
Author

Like this?

::: {.content-visible when-format="html"}
```pseudocode
#| label: alg-pruning
#| html-indent-size: "1.2em"
#| html-comment-delimiter: "//"
#| html-line-number: true
#| html-line-number-punc: ":"
#| html-no-end: false
#| pdf-placement: "htb!"
#| pdf-line-number: true
\begin{algorithm}
\caption{...}
\begin{algorithmic}
\Procedure{...}{...}
  \State ...
  \Return ...
\EndProcedure
\end{algorithmic}
\end{algorithm}
```
:::

and

::: {.content-hidden when-format="html"}
```pseudocode
#| label: alg-pruning
#| html-indent-size: "1.2em"
#| html-comment-delimiter: "//"
#| html-line-number: true
#| html-line-number-punc: ":"
#| html-no-end: false
#| pdf-placement: "htb!"
#| pdf-line-number: true
\begin{algorithm}
\caption{...}
\begin{algorithmic}
\Procedure{...}{...}
  \State ...
  \State\Return ...
\EndProcedure
\end{algorithmic}
\end{algorithm}
```
:::

with \Return alone for html output and \State\Return for pdf output?

If so, I am happy that there is a workaround, but this will create a lot of duplicate code in my .qmd submission.

@durandg12
Copy link
Author

The workaround worked for algorithms.

I discovered that my figures (generated with R code) are different in html and pdt outputs, so I tried the workaround with them too, in hopes of fine tuning the graphical parameters differently for html and pdf outputs. It didn't work in that case. Apparently, the labeling of the figures with #| label: is the origin of the problem. Quarto seems to believe that I am trying to attribute the same label to two different figures, because I get the error message

  Duplicate chunk label 'fig-benchmark01', which has been used for the chunk:

Strangely enough, I was also labelling my algorithms with the same syntax so I don't get it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants