0
votes

I'm preparing a document that contains colored tables (using colortbl) and to correct the thin white lines that appear in those tables I'm using a custom new line macro to compensate for that. However, AUCTeX does not recognize the new macro and tries to indent the table in a strange way.

\begin{table}[h]
  \centering\sffamily
  \begin{tabular}{lcc}
    \rowcolor{row1} \textbf{Nominative} & \emph{Wer?} & Who? \mynewline
                                                        \rowcolor{row2}\textbf{Accusative} & \emph{Wen?} & Who(m)? \\
    \rowcolor{row1} \textbf{Dative} & \emph{Wem?} & To who(m)? \\
    \rowcolor{row2} \textbf{Genitive} & \emph{Wessen?} & Whose? \mynewline
  \end{tabular}
\end{table}

How can I make AUCTeX understand that \mynewline plays the same role as \\?

1

1 Answers

1
votes

In many cases, AUCTeX should be able to learn about your own commands automatically if you set TeX-parse-self and TeX-auto-save to t. See https://www.gnu.org/software/auctex/manual/auctex/Parsing-Files.html#Parsing-Files

If that is not sufficient, you can tell AUCTeX about your own macros and environment using a style file. See https://www.gnu.org/software/auctex/manual/auctex/Style-Files.html#Style-Files for more on this. It boils down to using the function TeX-add-symbols correctly.

Please note that it's been a few years since I last did this.

AUCTeX ships with a style file for longtable which seems to contain exactly what you need. See http://git.savannah.gnu.org/cgit/auctex.git/tree/style/longtable.el#n92

(TeX-add-symbols
    ;; Commands to end table rows
    '("endhead" 0)
    '("endfirsthead" 0)
    '("endfoot" 0)
    '("endlastfoot" 0)
    ;; Caption commands
    '("caption*" 1))