I'm writing C++ code in latex with listings.
I'm trying to get listings to recognise the suffix .t() as a keyword (it means matrix transpose in the Armadillo C++ library).
I tried to get the ., ( and ) recognised as letters (as suggested in the listings manual and here) with alsoletter={.,(,)} while adding .t() as a keyword, but it didn't work.
I also saw a solution which involved defining the keyword as a comment, which I would rather not do, because I need comments for different purposes.
Below is a minimal reproducible example:
\documentclass[10pt,a4paper,]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{listings}
\lstnewenvironment{Cppinput}[1][]{
\lstset{%
language={C++},
alsoletter={.,(,)}, % I also tried {.t()}
morekeywords={mat, .t() , ones},
morecomment=[l]//,
basicstyle= \ttfamily,
keywordstyle= \color{BrickRed},
frame=single,
#1
}
}{}
\begin{document}
\begin{Cppinput}
using namespace arma;
mat A;
mat B;
mat C,
A = B + ones<mat>(n,1) + C.t();
// the ".t()" should be highlited as a keyword.
\end{Cppinput}
\end{document}
I have a hunch that the solution may involve alsoother=(), but I can't undertand its syntax from the manual and it didn't word in my example as alsoother=(.t())

