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

Separate settings for the math environments #80

Closed
matsievskiysv opened this issue Aug 15, 2017 · 9 comments
Closed

Separate settings for the math environments #80

matsievskiysv opened this issue Aug 15, 2017 · 9 comments
Labels
bug unexpected behaviour; should be a priority for fixing 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

Comments

@matsievskiysv
Copy link

For the different types of math equations different indent stiles are useful. For text with small equations it's ok not to indent at all. For bigger equations it's better to start each brace with new line and indent them. It would be nice to have separate settings block just for the math environments to think about them separately and allow more control over their indent.

Consider this example of the moderately big equation:

\begin{multline}
	\cosh{(\alpha D)} =
	\frac{-(K^E - K^H) \cos{\varphi}}
	{2 Q^2 (K^H + K^E)^2 \sin^2{\varphi} + K^H K^E \cos^2{\varphi}}
        \pm
\\
        \pm
	\left[
		(K^E - K^H)^2 \cos^2{\varphi} +
		4 (Q^2 (K^H + K^E)^2 \sin^2{\varphi}+
		K^E K^H \cos^2{\varphi}) \times
	\right.
\\
        \left.
		\times (1 + Q^2 (K^E + K^H)^2 \sin^2{\varphi})
	\right]^{1/2}
	\left[
		2 Q^2 (K^H + K^E)^2 \sin^2{\varphi}+
		K^H K^E \cos^2{\varphi}
	\right]^{-1}
\end{multline}
@cmhughes
Copy link
Owner

Have you looked at 'indentRules'? :)

@matsievskiysv
Copy link
Author

Thanks, somehow I missed this part.
I still have problem with braces though. How to enable indent between them? I tried to add them to indentRules and to enable UnNamedGroupingBracesBrackets. It didn't help.

@cmhughes
Copy link
Owner

Could you provide a minimum file, together with what your desired output would be?

@matsievskiysv
Copy link
Author

Here is the example:

\documentclass[12pt,a4paper]{report}
\begin{document}
\begin{equation}
\left(
\left[
\left\{
\sqrt{
a+b
}
\right\}
\right]
\right)
\end{equation}
\end{document}

and I would like it to look like this:

\documentclass[12pt,a4paper]{report}
\begin{document}
\begin{equation}
	\left(
		\left[
			\left\{
				\sqrt{
					a+b
				}
			\right\}
		\right]
	\right)
\end{equation}
\end{document}

@cmhughes
Copy link
Owner

Thanks very much for the follow-up, it's very helpful!

If I use the following yaml file:

seregaxvm.yaml

commandCodeBlocks:
    roundParenthesesAllowed: 0
specialBeginEnd:
    leftRightRound:
        begin: '\\left\('
        end: '\\right\)'
        lookForThis: 1
    leftRightSquare:
        begin: '\\left\['
        end: '\\right\]'
        lookForThis: 1
    leftRightCurly:
        begin: '\\left\\\{'
        end: '\\right\\\}'
        lookForThis: 1

and run

latexindent.pl myfile.tex -l=seregaxvm.yaml

then I receive the following output

\documentclass[12pt,a4paper]{report}
\begin{document}
\begin{equation}
	\left(
		\left[
			\left\{
				\sqrt{
					a+b
				}
			\right\}
			\right]
	\right)
\end{equation}
\end{document}

This is nearly correct, but the problem is that latexindent.pl is picking up \left[...] as a command and is not giving itself the option to find \left[ as a specialBeginEnd.

Given that this behaviour is undesired, I'm going to label this as a bug. I've got a few ideas on how to fix it -- leave it with me, and I'll return to this.

Thanks again for raising it.

@cmhughes cmhughes added bug unexpected behaviour; should be a priority for fixing enhancement enhancement which might be to an existing feature or the development of a new feature labels Aug 16, 2017
@matsievskiysv
Copy link
Author

Thank you! This helped a lot!

cmhughes added a commit that referenced this issue Aug 17, 2017
#80

This commit allows a new switch in specialBeginEnd that
allows the user to tell latexindent to search for specialBeginEnd
before searching for commands
@cmhughes
Copy link
Owner

As of e218223 I'd say that this is resolved. It'll be part of the next release, V3.3.

Thanks again for raising this!

@cmhughes cmhughes added the implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix label Aug 18, 2017
@cmhughes cmhughes mentioned this issue Aug 21, 2017
@cmhughes
Copy link
Owner

Thanks again, this is resolved as of #83

@cmhughes
Copy link
Owner

New version to be uploaded to ctan momentarily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected behaviour; should be a priority for fixing 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
Projects
None yet
Development

No branches or pull requests

2 participants