I am trying to make lingmacros gloss automatically be aware of the number of columns it will need to produce. Basically, for the \shortex command, one of the inputs is the number of columns you want to produce. This is equivalent to the number of times that "&" appears in the actual gloss text plus one. I've seen a way to get the number of occurrences of a string from this post, but when I try to make a macro for it, it gives me a "no number detected" error. Here is the basic code:
\documentclass{article}
\usepackage{xparse}
\usepackage{expl3}
\usepackage{lingmacros}
\ExplSyntaxOn
\NewDocumentCommand{\CountSubStr}{ m m }{%
\seq_set_split:Nnn \l_tmpa_seq { #1 } { #2 }%
\int_eval:n {(\seq_count:N \l_tmpa_seq)}%
}
\ExplSyntaxOff
% \CountSubStr{<substring>}{<string>}
\newcommand{\glossthis}[3]{%
\shortex{\CountSubStr{&}{#1}}
{#1}{#2}{#3}}
\begin{document}
\enumsentence{\glossthis%
{?& \.{I}ki & karde\c{s}-im & var. & Hi\c{c}-biri & kitap & oku-mu-yor-0.}
{& two & sibling-\textsc{1.sg} & have. & no-one & book & read-\textsc{neg}-\textsc{imperf}-\textsc{agr}.}
{`I have two siblings. None of them have read the book.'}}
\end{document}
I imagine the easiest way to change this is to modify the \CountSubStr command so that it outputs an actual number, rather than a string. Is this true? And how do I fix this issue?
\documentclassby the way. – cfr Oct 13 '19 at 01:03