0

Have seen that strange things start to happen as soon as one introduces blank lines between code sections.

For instance, take the synopsis for \NewDocumentEnvironment

\NewDocumentEnvironment{<environment-name>}{<code-at-begin>}{<code-at-end>}

If one introduces a blank line between {<environment-name>} and {<code-at-begin>}. As well as when a blank line is introduced between {<code-at-begin>} and {<code-at-end>}. Why has the latex language been designed to be so difficult to work with.

\NewDocumentEnvironment {<environment-name>}
  %% Some description here

{ <code-at-begin> }

%% Some description here { <code-at-end> }

Is one allowed to introduce comment lines like so

\NewDocumentEnvironment {<environment-name>}
  %% Some description here
  {
    <code-at-begin> 
  }
  %% Some description here
  { 
    <code-at-end> 
  }
  • 3
    well latex is about typesetting. And in typesetting spaces and line breaks and paragraphs spaces matters. Your second case will work (if you add the missing argument for the parameter specification), but the spaces after the braces can lead to spaces in the code. – Ulrike Fischer Oct 11 '23 at 16:32
  • 3
    You only have one question which is easily testable by adding it to a minimal document and compiling. Have you tried that? – Werner Oct 11 '23 at 16:37
  • @UlrikeFischer You are right, but here we are talking about code. Development of code in regard to its structure should not allow blank lines to affect the output result. If one wants a space, there should be appropriate commands for that to be used in code. –  Oct 11 '23 at 17:00
  • I also disapprove the use of % after braces when organising code on consecutive lines. –  Oct 11 '23 at 17:02
  • 1
    BTW, note that \NewDocumentEnvironment takes four arguments: you're missing the parameters. But if you wrap the definition between \ExplSyntaxOn and \ExplSyntaxOff then it'll work as you seem to want. – campa Oct 11 '23 at 17:22
  • 2
    a blank line is a paragraph break, so the real question is why are you adding end of paragraph commands at these points?i – David Carlisle Oct 11 '23 at 17:49
  • 1
    of course you can have comments, as you could easily have tested – David Carlisle Oct 11 '23 at 17:52
  • If a blank line was a paragraph break for authors I would not complain. Imposing it upon the programming language itself was not a good thing. –  Oct 11 '23 at 18:51
  • @DavidCarlisle My intention had been to organise the style/class code better, rather than introduce paragraph breaks. –  Oct 11 '23 at 18:53
  • That is built in at a very low level in tex-the-program not latex, but anyway (as you know) latex offers an \ExplSyntaxOn environment for programmers where white space is ignored, so you should have no complaints. – David Carlisle Oct 11 '23 at 18:54
  • "My intention had been to organise the style/class code better, rather than introduce paragraph breaks. " so that's user error then. a blank line is parsed as \par (which is the token latex sees) – David Carlisle Oct 11 '23 at 18:55
  • @campa Correct , There should be the parameters, but they are not the most problematic when arranging one's code. I have included \ExplSyntaxOn at the beginning of the file but not inside each environment. Something might be going wrong. –  Oct 11 '23 at 18:56
  • 3
    you can't put ExplSyntaxOn inside an environment just put it before the definitions you show and ExplSyntaxOff after them. Once again, there is no test file in the question. – David Carlisle Oct 11 '23 at 19:01
  • Shall put a test file because it does not seem to work as you are describing. –  Oct 11 '23 at 19:21

0 Answers0