2

I'm using latex to do syntactical analysis, using the following specifications:

 For super-script \tss{super-script}
\newcommand*{\tss}[1]{\textsuperscript{#1}}
\newcommand\tabspace{1cm}           % Adjust tab length here
\newcommand\mytabs{\hspace{\tabspace}\=\hspace{\tabspace}\=\hspace{\tabspace}\=\hspace{\tabspace}\=\hspace{\tabspace}\=}    

\newenvironment{syntax}[1][\mytabs] % The syntax environment, used for syntactical analyses
  {\begin{tabbing}#1\kill}
  {\end{tabbing}}
\newcommand{\tab}[2][\>]{#1 #2}     % Tab command, used in syntactical analyses

Currently, I can make five times \tab. My question is how I can change the number of possible \tab(s), so at to make it larger.

3
  • 2
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Jul 11, 2014 at 13:08
  • well you have 5 tabs set in \mytabs which can obviously be extended, but tabbing is a pretty useless latex environment so often it's best not to base the markup on tabbing. It is hard to offer any advice given the lack of information in the question. Please always make a complete (small) document that shows what you are trying to do. Jul 11, 2014 at 13:36
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Jul 11, 2014 at 13:43

1 Answer 1

1

You could simply add other twenty \=\hspace{\tabspace} commands in the definition of \mytabs, so as to have sufficient room for your tabbing environments.

Here's a different approach. The syntax environment has an optional argument (default 5) for the number of columns; the syntax* environment wants instead an explicit line to be \killed, for setting unequal tab spaces.

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentEnvironment{syntax}{O{5}}
 {
  \begin{tabbing}
  \prg_replicate:nn { #1 } { \=\hspace{\tabspace} }\kill
 }
 {
  \end{tabbing}
 }
\NewDocumentEnvironment{syntax*}{m}
 {
  \begin{tabbing}
  #1\kill
 }
 {
  \end{tabbing}
 }
\ExplSyntaxOff

\newcommand\tabspace{1cm}           % Adjust tab length here
\newcommand{\tab}[2][\>]{#1#2}

\begin{document}

\begin{syntax}
\tab{a}\tab{b}\tab{c}\tab{d}\tab{e}\\
\tab{1}\tab{2}\tab{3}\tab{4}\tab{5}
\end{syntax}

\begin{syntax}[6]
\tab{a}\tab{b}\tab{c}\tab{d}\tab{e}\tab{f}\\
\tab{1}\tab{2}\tab{3}\tab{4}\tab{5}\tab{6}
\end{syntax}

\begin{syntax*}{\=aaa\=bbb\=ccccccc\=d}
\tab{a}\tab{b}\tab{c}\tab{d}\\
\tab{1}\tab{2}\tab{3}\tab{4}
\end{syntax*}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .