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

linewidth not respected exactly with indentation #359

Closed
tdegeus opened this issue Apr 24, 2022 · 9 comments
Closed

linewidth not respected exactly with indentation #359

tdegeus opened this issue Apr 24, 2022 · 9 comments
Labels
enhancement enhancement which might be to an existing feature or the development of a new feature implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix one-sentence-per-line one sentence per line; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch text-wrap text wrapping; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html

Comments

@tdegeus
Copy link
Contributor

tdegeus commented Apr 24, 2022

Please provide the following when posting an issue:

original .tex code

\begin{abstract}
    This is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
\end{abstract}

yaml settings

onlyOneBackUp: 1
defaultIndent: '    '
removeTrailingWhitespace: 1

lookForAlignDelims:
  align: 0

modifyLineBreaks:
  oneSentencePerLine:
    manipulateSentences: 1
    removeSentenceLineBreaks: 0
    textWrapSentences: 1
    sentencesFollow:
      other: |-
        (?x)
        \\caption\{\h*\R*
        \\footnote\{\h*\R*
  textWrapOptions:
    columns: 100

fineTuning:
  namedGroupingBracesBrackets:
    name: '[0-9\.a-zA-Z@\*><_]+?'

# remove recurrent spaces
replacements:
- substitution: s/([a-zA-Z0-9.}{])\h{2,}([a-zA-Z0-9.}{])/$1 $2/sg
  when: before
- substitution: s/([a-zA-Z0-9.()}{])\h{2,}([a-zA-Z0-9.()}{]|(?:\\(?!\\)))/$1 $2/sg
  when: after

actual/given output

\begin{abstract}
    This is a very long sentence that should be wrapped at some point, which is the case but is is is
    is line width is not respected because of the indentation.
\end{abstract}

desired or expected output

\begin{abstract}
    This is a very long sentence that should be wrapped at some point, which is the case but is is 
    is is line width is not respected because of the indentation.
\end{abstract}
@cmhughes
Copy link
Owner

Thanks for this.

So if there was no indentation then the line width would be correct....?

@tdegeus
Copy link
Contributor Author

tdegeus commented Apr 24, 2022

Indeed

@cmhughes
Copy link
Owner

OK, in which case this is a known issue : https://latexindentpl.readthedocs.io/en/latest/sec-conclusions-know-limitations.html

I'll see if I can look into changing the order of things. I have no idea how difficult it will be.

Text wrapping is the gift that keeps on giving.

@cmhughes cmhughes added text-wrap text wrapping; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html one-sentence-per-line one sentence per line; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch labels Apr 24, 2022
@tdegeus
Copy link
Contributor Author

tdegeus commented Apr 24, 2022

In that case sorry for reporting a know issue ;)
Don't worry nothing urgent/important. Just reporting in order to help the project

@cmhughes
Copy link
Owner

For my reference

#306

@cmhughes cmhughes added the enhancement enhancement which might be to an existing feature or the development of a new feature label May 20, 2022
@cmhughes
Copy link
Owner

This issue is on my mind a lot, I have a plan for how to tackle it, just need the head space to sit down and do it.

I'm hoping to get to it before the end of 2022, at the latest.

@cmhughes
Copy link
Owner

For my reference

#356

@cmhughes
Copy link
Owner

cmhughes commented Dec 21, 2022

Some good news! :)

As of a54b7be I've upgraded the text wrap routine.

demonstration 1

Starting with

\begin{abstract}
    This is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.  Another is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
    \begin{another}
    Another is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
    \begin{itemize}
      \item Another is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation. One is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation. Two is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
      \item Another is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation. One is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation. Two is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
      \item Another is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
    \begin{itemize}
      \item One is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
      \item Two is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
    \end{itemize}
      \item Three is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
    \end{itemize}
    \end{another}
    This is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation. One is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation. Two is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation. Three is a very long sentence that should be wrapped at some point, which is the case but is is is is line width is not respected because of the indentation.
\end{abstract}

and the settings

defaultIndent: '    '

modifyLineBreaks:
    oneSentencePerLine:
      manipulateSentences: 1
      textWrapSentences: 1
      sentencesFollow:
          other: \\item
    textWrapOptions:
        columns: 100
        when: after                          # <!----------  NEW BIT

gives the output

\begin{abstract}
    This is a very long sentence that should be wrapped at some point, which is the case but is is
    is is line width is not respected because of the indentation.
    Another is a very long sentence that should be wrapped at some point, which is the case but is
    is is is line width is not respected because of the indentation.
    \begin{another}
        Another is a very long sentence that should be wrapped at some point, which is the case but
        is is is is line width is not respected because of the indentation.
        \begin{itemize}
            \item
                  Another is a very long sentence that should be wrapped at some point, which is
                  the case but is is is is line width is not respected because of the indentation.
                  One is a very long sentence that should be wrapped at some point, which is the
                  case but is is is is line width is not respected because of the indentation.
                  Two is a very long sentence that should be wrapped at some point, which is the
                  case but is is is is line width is not respected because of the indentation.
            \item
                  Another is a very long sentence that should be wrapped at some point, which is
                  the case but is is is is line width is not respected because of the indentation.
                  One is a very long sentence that should be wrapped at some point, which is the
                  case but is is is is line width is not respected because of the indentation.
                  Two is a very long sentence that should be wrapped at some point, which is the
                  case but is is is is line width is not respected because of the indentation.
            \item
                  Another is a very long sentence that should be wrapped at some point, which is
                  the case but is is is is line width is not respected because of the indentation.
                  \begin{itemize}
                      \item
                            One is a very long sentence that should be wrapped at some point, which
                            is the case but is is is is line width is not respected because of the
                            indentation.
                      \item
                            Two is a very long sentence that should be wrapped at some point, which
                            is the case but is is is is line width is not respected because of the
                            indentation.
                  \end{itemize}
            \item
                  Three is a very long sentence that should be wrapped at some point, which is the
                  case but is is is is line width is not respected because of the indentation.
        \end{itemize}
    \end{another}
    This is a very long sentence that should be wrapped at some point, which is the case but is is
    is is line width is not respected because of the indentation.
    One is a very long sentence that should be wrapped at some point, which is the case but is is
    is is line width is not respected because of the indentation.
    Two is a very long sentence that should be wrapped at some point, which is the case but is is
    is is line width is not respected because of the indentation.
    Three is a very long sentence that should be wrapped at some point, which is the case but is is
    is is line width is not respected because of the indentation.
\end{abstract}
----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
   5   10   15   20   25   30   35   40   45   50   55   60   65   70   75   80   85   90   95   100   105   110

Note that columns have been respected :)

demonstration 2

Starting with

\begin{enumerate}
\item This is a very long sentence, which is mostly likely going to be longer than eighty characters---and it is.
\item This is a very long sentence, which is mostly likely going to be longer than eighty
characters---in fact, it is. But it's wrapped on one hundred characters, yes 100.
\end{enumerate}

and the settings

defaultIndent: "  "
modifyLineBreaks:
  textWrapOptions:
    columns: 80
    when: after    #<!------- NEW BIT

gives the output

\begin{enumerate}
  \item This is a very long sentence, which is mostly likely going to be longer
        than eighty characters---and it is.
  \item This is a very long sentence, which is mostly likely going to be longer
        than eighty characters---in fact, it is. But it's wrapped on one
        hundred characters, yes 100.
\end{enumerate}
----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
   5   10   15   20   25   30   35   40   45   50   55   60   65   70   75   80   85   90

demonstration 3

From #306, starting with

\begin{document}
\begin{enumerate}[label=(\alph*)]
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit, cras imperdiet viv ris et molestie. Nulla molestie diam quam, ac molestie velit rhoncus placerat.
\begin{enumerate}[label=(\roman*)]
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit, cras imperdiet viv ris et molestie. Nulla molestie diam quam, ac molestie velit rhoncus placerat.
\end{enumerate}
\end{enumerate}
\end{document}

Using the settings

defaultIndent: '    '

modifyLineBreaks:
    textWrapOptions:
        columns: 100
        when: after                          # <!---- NEW BIT

gives the output

\begin{document}
\begin{enumerate}[label=(\alph*)]
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit, cras
          imperdiet viv ris et molestie. Nulla molestie diam quam, ac molestie
          velit rhoncus placerat.
          \begin{enumerate}[label=(\roman*)]
              \item Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                    cras imperdiet viv ris et molestie. Nulla molestie diam
                    quam, ac molestie velit rhoncus placerat.
          \end{enumerate}
\end{enumerate}
\end{document}
----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
   5   10   15   20   25   30   35   40   45   50   55   60   65   70   75   80   85   90   95   100   105   110

You'll notice that the text wrapping can now respect columns and indentation!

This will be part of the next release, coming soon in early 2023, hopefully :) Feel free to pull from develop if you're interested in testing :)

@cmhughes cmhughes added the implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix label Dec 21, 2022
@cmhughes
Copy link
Owner

cmhughes commented Jan 1, 2023

This is part of V3.20 at https://github.com/cmhughes/latexindent.pl/releases/tag/V3.20. I've uploaded it to ctan. Many thanks!

@cmhughes cmhughes closed this as completed Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement enhancement which might be to an existing feature or the development of a new feature implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix one-sentence-per-line one sentence per line; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch text-wrap text wrapping; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html
Projects
None yet
Development

No branches or pull requests

2 participants