Closed Andrew15-5 closed 1 year ago
Yes, that's the one to start from.
modifyLineBreaks:
textWrapOptions:
blocksFollow:
other: |-
(?x)
\\\]
|
\\item(?:\h|\[)
|
\\begin\{(?:minipage|flushright|myenv)\} # <--- new bit
Could you please describe what this regex actually does/consists of? I know, for example, what \\item(?:\h|\[)
or \\begin\{(?:minipage|flushright|myenv)\}
mean (I think \\\]
refers to \item[...]
). But all the other bits (i.e., |-
, (?x)
, |
, linefeed \n
, long indentations) I don't really understand. I'm guessing that |
is the same as in (a|b|c)
but there is no parenthesis and there are big indentations + new lines. Maybe it is something that is ignored and simply done for distinguishing between different bits of regex that are actually used by the formatter.
If the answer already exists somewhere, please provide a link.
Can you look at the details I give in the following :
https://latexindentpl.readthedocs.io/en/latest/sec-fine-tuning.html#fine-tuning
https://latexindentpl.readthedocs.io/en/latest/sec-replacements.html#lst-multi-line
On Thu, 9 Mar 2023, 13:00 Andrew Voynov, @.***> wrote:
Could you please describe what this regex actually does/consists of? I know, for example, what \item(?:\h|[) or \begin{(?:minipage|flushright|myenv)} mean (I think \] refers to \item[...]). But all the other bits (i.e., |-, (?x), |, linefeed \n, long indentations) I don't really understand. I'm guessing that | is the same as in (a|b|c) but there is no parenthesis and there are big indentations
- new lines. Maybe it is something that is ignored and simply done for distinguishing between different bits of regex that are actually used by the formatter.
— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/432#issuecomment-1462023223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYFCBURJWZSTHNNZXZDW3HH5DANCNFSM6AAAAAAVUKJFIE . You are receiving this because you commented.Message ID: @.***>
Thank you. Now I more understand than not understand.
I found a new issue where I can't wrap text inside \caption{...}
and then changed blocksBeginWith:other:
from "[а-яёА-ЯЁ]"
to:
modifyLineBreaks:
textWrapOptions:
blocksBeginWith:
other: |-
(?x)
[а-яёА-ЯЁ]
|
\\caption\{
And it works. But only outside any environment. If I have a simple:
\begin{table}
\caption{text text text text text text text text text text text text text text text text}
\end{table}
It doesn't work. But then I added this:
modifyLineBreaks:
textWrapOptions:
blocksFollow:
other: |-
(?x)
\\\]
|
\\item(?:\h|\[)
|
\\begin\{(?:table)\}(?:\[.*?\])?
And now it works, good. But it doesn't add the indent:
\begin{table}
\caption{text text text text text text text text text text text text text text
text text}
\end{table}
If I remove \\caption\{
then it will add the indent:
\begin{table}
\caption{text text text text text text text text text text text text text text
text text}
\end{table}
But if I straighten up the \caption{...}
line (back into a single line), then it again wouldn't wrap the text.
So I have to
\\caption\{
\\caption\{
to get the desirable formatting. Is there a way without modifying the config back and forth?
It looks like you want
modifyLineBreaks:
textWrapOptions:
blocksFollow:
other: |-
(?x)
\\\]
|
\\item(?:\h|\[)
|
\\begin\{(?:table)\}(?:\[.*?\])
|
\\caption\{
Almost. This is an output:
\begin{table}
\caption{text text text text text text text text text text text text text text
text text}
\end{table}
So it's not 2 spaces, and it's not after the \caption{
(9 spaces). Maybe the latter would be better.
If I change \\begin\{(?:table)\}(?:\[.*?\])?
to \\begin\{(?:table)\}(?:\[.*?\])?\h
then it works:
\begin{table}
\caption{text text text text text text text text text text text text text text
text text}
\end{table}
But I added \h
in the "wrong" place. What if I don't want to add the same formatting for a different macro (e.g., \notACaption{...}
)? In other words, I want low coupling between table
environment and caption
macro (i.e., add \h
to \caption
instead of table
). Maybe I don't something (maybe it is the right way).
You need to specify blocksBeginWith
and blocksFollow
to suit your needs.
I admit I'm so lost I don't even really know the difference sometime, but in the end I think I found a solution (I don't know if it is a correct one):
modifyLineBreaks:
textWrapOptions:
blocksBeginWith:
other: |-
(?x)
[а-яёА-ЯЁ]
|
\\begin\{(?:table)\}(?:\[.*?\])?
blocksFollow:
other: |-
(?x)
\\\]
|
\\item(?:\h|\[)
|
\\begin\{(?:center|flushleft|flushright|minipage)\}
|
\\(?:caption)\{
original .tex code
yaml settings
actual/given output
desired or expected output
anything else
I'm sorry but the regex https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html?highlight=brackets#lst-tw-bf-myenv-yaml looks very confusing (aside from a massive size) and hard to understand (if I'm even referencing the right thing for the issue). Hence, I need help with the problem. I also don't understand if I have to do this long regex for each environment name (it will become even bigger).
I need to format paragraphs inside any environment (
center
,minipage
,flushright
etc.) — add linebreaks at 81st column. Well, not exactly any environment (exceptions are any verbatim environments and similar) but you know what I mean.P.S.
Sorry for so many issues, I hope I'm not irritating you or anything. :P