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

Incorrect indentation when \AgdaHide is used #2623

Closed
nad opened this issue Jul 2, 2017 · 6 comments
Closed

Incorrect indentation when \AgdaHide is used #2623

nad opened this issue Jul 2, 2017 · 6 comments
Labels
backend: latex LaTeX generation backend type: bug Issues and pull requests about actual bugs
Milestone

Comments

@nad
Copy link
Contributor

nad commented Jul 2, 2017

Consider the following code:

\documentclass{article}

\usepackage{agda}

\pagestyle{empty}

\begin{document}

\noindent Text.
\AgdaHide{
\begin{code}
  mutual
\end{code}}
\begin{code}
    postulate A : Set
\end{code}
More text.
\begin{AgdaMultiCode}{2}
\begin{code}
  mutual
\end{code}
\begin{code}
    postulate B : Set
\end{code}
\end{AgdaMultiCode}
Even more text.

\end{document}

In the resulting document the two code blocks are not aligned:

bug

As a workaround one can add a module header, and make sure that everything is indented relative to it:

\documentclass{article}

\usepackage{agda}

\pagestyle{empty}

\begin{document}

\AgdaHide{
\begin{code}
module Bug where
\end{code}}

\noindent Text.
\AgdaHide{
\begin{code}
  mutual
\end{code}}
\begin{code}
    postulate A : Set
\end{code}
More text.
\begin{AgdaMultiCode}{2}
\begin{code}
  mutual
\end{code}
\begin{code}
    postulate B : Set
\end{code}
\end{AgdaMultiCode}
Even more text.

\end{document}

bug

@nad nad changed the title Incorrect indentation when \ Incorrect indentation when \AgdaHide is used Jul 2, 2017
@nad nad added backend: latex LaTeX generation backend type: bug Issues and pull requests about actual bugs labels Jul 2, 2017
@nad nad added this to the 2.5.3 milestone Jul 2, 2017
@nad
Copy link
Contributor Author

nad commented Jul 2, 2017

By the way, I found a way to quickly generate PNG files without lots of empty space for use in bug reports:

  • Make sure that the document does not contain a page number, for instance by using \pagestyle{empty}.
  • Use the ImageMagick command convert in the following way to create the image file:
    convert -density 150 -trim Bug.pdf Bug.png
    
    (The density value could perhaps be a bit lower.)

@andreasabel
Copy link
Member

I tried your original example, and found it looks even more wrong when the \AgdaHide is not used.
I did not know that this was even legal Agda code, indentation without a layout keyword. I think the base indentation should be at column 1, everything else should be a syntax error.

@andreasabel andreasabel changed the title Incorrect indentation when \AgdaHide is used Incorrect indentation in LaTeX when base indentation is not column 1. Jul 2, 2017
@nad
Copy link
Contributor Author

nad commented Jul 2, 2017

I tried your original example, and found it looks even more wrong when the \AgdaHide is not used.

From the CHANGELOG: "Note that if any token in L or E belongs to a previous code block, then the constraint may not be satisfied unless (say) the AgdaAlign environment is used in an appropriate way." If you use (say) AgdaMultiCode, then the code without \AgdaHide is unproblematic:

\noindent Text.
\begin{AgdaMultiCode}{2}
\begin{code}
  mutual
\end{code}
\begin{code}
    postulate A : Set
\end{code}
\end{AgdaMultiCode}
More text.
\begin{AgdaMultiCode}{2}
\begin{code}
  mutual
\end{code}
\begin{code}
    postulate B : Set
\end{code}
\end{AgdaMultiCode}
Even more text.

@nad nad changed the title Incorrect indentation in LaTeX when base indentation is not column 1. Incorrect indentation when \AgdaHide is used Jul 2, 2017
@UlfNorell UlfNorell modified the milestones: 2.5.4, 2.5.3 Aug 9, 2017
@nad
Copy link
Contributor Author

nad commented Sep 7, 2017

The example in the OP has been fixed by 2d85838. However, I'm not satisfied with how the following code is handled:

\documentclass{article}

\usepackage{agda}

\pagestyle{empty}

\begin{document}

\begin{AgdaAlign}
\begin{code}
  postulate
   A : Set
\end{code}
\AgdaHide{
\begin{code}
  mutual
\end{code}}
\begin{code}
    postulate B : Set
\end{code}
\end{AgdaAlign}

\end{document}

Output:

issue2623-2

I think \AgdaHide should be deprecated in favour of an environment that does not typeset its contents, but still performs the same kind of bookkeeping as the code environment.

@nad
Copy link
Contributor Author

nad commented Sep 9, 2017

Upon closer thought I think that the code above is handled in a reasonable way, assuming that it should be handled at all, rather than throwing an error message.

Here is a different example, that one might expect should work:

\documentclass{article}

\usepackage{agda}
\AgdaNoSpaceAroundCode{}

\pagestyle{empty}

\begin{document}

\begin{AgdaAlign}
\begin{code}
postulate
  A
\end{code}
\AgdaHide{
\begin{code}
    B
\end{code}}
\begin{code}
    C : Set
\end{code}
\end{AgdaAlign}

\end{document}

Output:

bug

Should we even try to handle code of this form?

nad added a commit that referenced this issue Sep 9, 2017
@nad
Copy link
Contributor Author

nad commented Sep 9, 2017

I added a test case for the example in the OP.

@nad nad added the status: info-needed More information is needed from the bug reporter to confirm the issue. label Sep 19, 2017
@jespercockx jespercockx removed the status: info-needed More information is needed from the bug reporter to confirm the issue. label May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: latex LaTeX generation backend type: bug Issues and pull requests about actual bugs
Projects
None yet
Development

No branches or pull requests

4 participants