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

Environment template: Unwanted newline at the beginning if there is only whitespace on the current line #58

Open
Sinthoras7 opened this issue Apr 25, 2023 · 4 comments

Comments

@Sinthoras7
Copy link

Currently, the environment templates, e.g. equ then tab, insert the environment on the current line, if the cursor is at the beginning of the line; and first create a new line and then insert the environment if the cursor is at a line, where things have been typed before, i.e. the cursor is not at the beginning of the line.

This behavior is mostly great, because the begin{equation} should have its own line and not be at the end of some line. A problem arises, when there is only whitespace on the current line before the cursor. In this case, the begin{equation} should be inserted in the same line, since the line is empty modulo whitespace.
But instead - I assume because the cursor is not at the beginning of the line, since there is whitespace before it - a new line gets inserted, creating a completely empty line between the text before and the begin{equation}.

This empty line is a problem, because Latex then interprets this as a new paragraph and inserts extra space between the text and the environment, e.g. the equation. (Also for aesthetic- and clarity-reasons in the .tex file, but those are secondary.)
This problem gets enhanced, because Auctex creates these whitespaces automatically, when creating a new line in the .tex file inside an environment.

@cdominik
Copy link
Owner

cdominik commented Jul 8, 2023

Hi, I am finally looking at that and can reproduce it. Easy to fix, in principle. However, cdlatex always inserts environments unindented. So if I simply no longer insert a newline, then the result might look like this:

    \begin{equation}

\label{...}
\end{equation}

i.e. with the first line indented, but the others not. Should I remove the white space at before the cursor?

@Sinthoras7
Copy link
Author

This is not perfect, (ideally cdlatex would detect the indent and act accordingly) but I personally think it is an okay fix and better than the behaviour right now, so you should remove it.

@cdominik
Copy link
Owner

cdominik commented Jul 9, 2023

Hi,

I have pushed a fix that does also keep the indentation. May I ask you to test it, Sinthoras, and report back? I have not yet changed the version number, so this will not yet move up into the package system.

@Sinthoras7
Copy link
Author

Hey, I tested it, and it seems to not have worked. It seems to have the same behaviour as before the fix.
I am not entirely, but like 85% sure, that I have the version currently in the repository including the newest commit installed.

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

No branches or pull requests

2 participants