# latexindent feature that ignore table headings when using alignDoubleBackSlash and delims in lookForAlignDelims under tabular #182

Closed
opened this issue Jan 16, 2020 · 13 comments
Closed

# latexindent feature that ignore table headings when using alignDoubleBackSlash and delims in lookForAlignDelims under tabular#182

opened this issue Jan 16, 2020 · 13 comments
Labels

### yangmw commented Jan 16, 2020

 I encountered an issue, whenever my table headings becomes longer then the table items their Ampersand aligns with huge spaces in between my table items like this: \begin{table}[htbp] \centering \caption{Add caption} \begin{tabular}{rrrrrrr} \toprule \multicolumn{1}{c}{Expiry} & Tenor & \multicolumn{1}{c}{$\Delta_{\text{call},10}$} & \multicolumn{1}{c}{$\Delta_{\text{call},25}$} & \multicolumn{1}{c}{$\Delta_{\text{call},50}$} & \multicolumn{1}{c}{$\Delta_{\text{call},75}$} & \multicolumn{1}{c}{$\Delta_{\text{call},90}$} \\ \midrule 30-03-2016 & 1D & -2E-14 & -2E-14 & 3E-14 & -8E-14 & -7E-14 \\ 05-04-2016 & 1W & -4E-15 & -1E-14 & 1E-14 & -6E-15 & -1E-14 \\ 12-04-2016 & 2W & 3E-15 & 1E-14 & 1E-14 & -3E-14 & -2E-14 \\ 27-04-2016 & 1M & -2E-16 & -2E-15 & -1E-14 & -7E-15 & -2E-15 \\ 27-05-2016 & 2M & 2E-15 & 7E-15 & 2E-15 & -4E-15 & 4E-15 \\ 28-06-2016 & 3M & -4E-15 & 3E-16 & -4E-15 & -2E-15 & -8E-15 \\ 28-09-2016 & 6M & 1E-16 & 3E-16 & 0 & -2E-15 & -5E-15 \\ 28-12-2016 & 9M & 1E-16 & 1E-15 & 2E-15 & 8E-15 & -3E-15 \\ 29-03-2017 & 1Y & 2E-16 & 2E-15 & 5E-15 & 1E-14 & 2E-14 \\ 27-03-2018 & 2Y & 1E-15 & 7E-16 & -2E-15 & 3E-16 & 5E-15 \\ 27-03-2019 & 3Y & -2E-16 & 1E-15 & -6E-16 & -2E-15 & -4E-15 \\ 27-03-2020 & 4Y & -2E-16 & 1E-16 & 5E-16 & -2E-16 & -8E-15 \\ 29-03-2021 & 5Y & 2E-16 & -4E-16 & 0 & -2E-15 & -2E-15 \\ \bottomrule \end{tabular}% \label{tab:addlabel}% \end{table}%  The settings in the .yaml is: lookForAlignDelims: tabular: delims: 1 alignDoubleBackSlash: 1 spacesBeforeDoubleBackSlash: 1 multiColumnGrouping: 0 alignRowsWithoutMaxDelims: 0 spacesBeforeAmpersand: 1 spacesAfterAmpersand: 1 justification: "right"  Is it possible for latexindent to ignore table headings? Then it would be very nice like this: \begin{table}[htbp] \centering \caption{Add caption} \begin{tabular}{rrrrrrr} \toprule \multicolumn{1}{c}{Expiry} & Tenor & \multicolumn{1}{c}{$\Delta_{\text{call},10}$} & \multicolumn{1}{c}{$\Delta_{\text{call},25}$} & \multicolumn{1}{c}{$\Delta_{\text{call},50}$} & \multicolumn{1}{c}{$\Delta_{\text{call},75}$} & \multicolumn{1}{c}{$\Delta_{\text{call},90}$} \\ \midrule 30-03-2016 & 1D & -2E-14 & -3E-14 & 1E-14 & -8E-14 & -1E-14 \\ 05-04-2016 & 1W & -0E-15 & -4E-14 & 2E-14 & -5E-15 & -5E-14 \\ 12-04-2016 & 2W & 9E-15 & 5E-14 & 3E-14 & -3E-14 & -6E-14 \\ 27-04-2016 & 1M & -8E-16 & -6E-15 & -4E-14 & -4E-15 & -7E-15 \\ 27-05-2016 & 2M & 7E-15 & 7E-15 & 5E-15 & -4E-15 & 8E-15 \\ 28-06-2016 & 3M & -6E-15 & 8E-16 & -6E-15 & -3E-15 & -1E-15 \\ 28-09-2016 & 6M & 5E-16 & 9E-16 & 0 & -2E-15 & -2E-15 \\ 28-12-2016 & 9M & 4E-16 & 2E-15 & 7E-15 & 8E-15 & -3E-15 \\ 29-03-2017 & 1Y & 3E-16 & 1E-15 & 8E-15 & 2E-14 & 4E-14 \\ 27-03-2018 & 2Y & 2E-15 & 4E-16 & -9E-15 & 3E-16 & 5E-15 \\ 27-03-2019 & 3Y & -1E-16 & 5E-15 & -1E-16 & -2E-15 & -6E-15 \\ 27-03-2020 & 4Y & -9E-16 & 6E-16 & 3E-16 & -2E-16 & -7E-15 \\ 29-03-2021 & 5Y & 8E-16 & -7E-16 & 0 & -2E-15 & -9E-15 \\ \bottomrule \end{tabular}% \label{tab:addlabel}% \end{table}%  Best wishes, Yang.
mentioned this issue Jan 23, 2020

### swaroopguggilam commented Jan 23, 2020

 As per our discussion, posting my request which is similar to above one, here, Firstly, thanks for this file, its really helpful. Following is my problem: \begin{alignat}{2} & asdfasdfadsaaaaaaaaaaadsaaaaaaaaaaaaaaaaaaaaaaasdfffffffffffffffffffff & & temp \\ & & & tempasdfasdf \\ \end{alignat}  After I format it using latexindent.pl, all the & align, but I don't want that, because as one of my word is very long, its affecting the visibility of all the rows in my latex file. Current Output: \begin{alignat}{2} & asdfasdfadsaaaaaaaaaaadsaaaaaaaaaaaaaaaaaaaaaaasdfffffffffffffffffffff & & temp \\ & & & tempasdfasdf \\ \end{alignat}  Required Output: \begin{alignat}{2} & asdfasdfadsaaaaaaaaaaadsaaaaaaaaaaaaaaaaaaaaaaasdfffffffffffffffffffff & & temp \\ & & & tempasdfasdf \\ \end{alignat}  Is there an option to do this? (I want something similar to \ (alignDoubleBackSlash: 0)) This is kind of similar to above request, but would still highlight following differences: That one particularly focus on ignoring table headings, mine is in general ampersand signs Mine above is under equations (alignat) and not tables, but I believe same command can be used for different type of blocks across latex like your other features. Basically "Dont align at & routine or a variable to set this false" would be very helpful. Thank you.

### cmhughes commented Mar 9, 2020

 Here's my current thinking on how the YAML for this might look: # option 1 (nothing happens, default) lookForAlignDelims: dontMeasure: 0 # option 2 (largest cell in each column is not counted for alignment) lookForAlignDelims: dontMeasure: largest # option 3 (user specifies specific strings to be ignored) lookForAlignDelims: dontMeasure: - \multicolumn{1}{c}{Expiry} - \multicolumn{1}{c}{$\Delta_{\text{call},10}$} # option 4 (user specifies either a string or a regex to be ignored, either on a cell or row basis) lookForAlignDelims: dontMeasure: - this: \multicolumn{1}{c}{Expiry} applyTo: cell - regex: \\multicolumn\{\d\}\{.\}\{.*?\} applyTo: row  Please note: the above is not a commitment to this interface, but reflects my current thinking. Feel free to input :)

### yangmw commented Mar 9, 2020

 Hi, I like the last option 4 :)

### cmhughes commented Mar 9, 2020

 I'm hoping to allow all of the above options to be valid :)

### swaroopguggilam commented Mar 9, 2020 • edited

 Thanks Chris for the update, I like your idea. I just have one question, does this solves the issue I mentioned? "About not aligning at &"? If yes, then what would be command/setting once you implement it? To elaborate: I understand that option 2 will ignore only the largest, what if there are varying lengths data in the column. Option 3 is specific strings. I believe using regex in option 4, is the close resemblance to my need. How do I apply option 4 for entire set of equations in the "alignat"?

### cmhughes commented Mar 9, 2020

 I'll report back once I've attempted this :) … On Mon, 9 Mar 2020, 20:17 swaroopguggilam, ***@***.***> wrote: Thanks Chris for the update, I like your idea. I just have one question, does this solves the issue I mentioned? "About not aligning at &"? If yes, then what would be command/setting once you implement it? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#182?email_source=notifications&email_token=AAQ7CYA7YBPCY527X4GOC3TRGVMGHA5CNFSM4KHRPJSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOI43YY#issuecomment-596757987>, or unsubscribe .

### yangmw commented Mar 9, 2020

 That would be even better! Thank you for doing this! And when you are done, could you also update the latexindent.exe file in https://ctan.org/tex-archive/support/latexindent :)
added a commit that referenced this issue Mar 10, 2020
 New feature: dont Measure, detailed within #182. Next: need to implem… 
 f3e60ed 
…ent the 'largest' option (option 2 in the link) and then documentation

### cmhughes commented Mar 10, 2020

 @yangmw @swaroopguggilam if you'd like to experiment, I've started a new branch as of f3e60ed You'll see that option 1, 3 and 4 are now available. I need to work on option 2, next. So far, it looks optimistic. You'll need to clone the https://github.com/cmhughes/latexindent.pl/tree/feature/dontMeasure branch, which is experimental at this time!

### yangmw commented Mar 10, 2020

 Excellent Chris! Thank you, I look forward to try it tomorrow.

### swaroopguggilam commented Mar 11, 2020

 Thanks Chris, will try out this weekend and let you know.
added a commit that referenced this issue Mar 11, 2020
 Merge branch 'feature/dontMeasure' into develop, #182 
 e6bb29c 

### cmhughes commented Mar 11, 2020

 All of the options detailed above are now implemented and documented in the develop branch, as of e6bb29c. Feel free to test and let me know. For the moment, I'm going to label this as implemented.
added the label Mar 11, 2020

## demonstration

starting with

\begin{tabular}{cccc}
aaaaaa&bbbbb&ccc&dd\\
11&2&33&4\\
5&66&7&8
\end{tabular}


and the YAML

lookForAlignDelims:
tabular:
dontMeasure: largest


gives

\begin{tabular}{cccc}
aaaaaa & bbbbb & ccc & dd \\
11 & 2  & 33 & 4          \\
5  & 66 & 7  & 8
\end{tabular}


There are other options for the dontMeasure routine, all demonstrated within the documentation.

mentioned this issue Mar 21, 2020

### cmhughes commented Mar 21, 2020

 Implemented in Version 3.8, #190
closed this Mar 21, 2020