1

I seem to have a problem with using \bTABLEbody and \eTABLEbody within macros. For example, I wanted to wrap these commands inside another command:

\def\BeginChemicalTable{%
  % ... other stuff goes here
  \bTABLE
    \bTABLEhead
      \bTR
        \bTH Chemical name \eTH
        \bTH Data \eTH
        \bTH Date \eTH
      \eTR
    \eTABLEhead
    \bTABLEbody
 }

 \def\EndChemicalTable{%
    \eTABLEbody
   \eTABLE
 }

When \bTABLEbody and \eTABLEbody are in different macros and I run ConTeXt, it halts and just leaves me at “Please enter a command or say \end” prompt, but when I replace \BeginChemicalTable and \EndChemicalTable with their respective contents and run throught ConTeXt again, it all works fine.

Am I trying to do something dumb, or are \bTABLEbody and \eTABLEbody known for not playing nice when in different macros?

  • Can you create a MWE? The standard way to do something like this is to use setups. \startsetup chemicaltable %... other stuff here \stopsetup and then \bTABLE[setups={chemicaltable}] ... \eTABLE – Aditya Dec 9 '15 at 14:29
2

You can’t put the begin and end tags for table blocks in custom macros because ConTeXt uses \eTABLEbody as delimiter for \bTABLEbody when it stores the content. You can get around this problem when you use the buffer mechanism to save the content of your custom environment and pass its content to the body block of the table.

\def\startChemicalTable
  {\grabbufferdata[ChemicalTable][startChemicalTable][stopChemicalTable]}

\def\stopChemicalTable
  {\bTABLE
     \bTABLEhead
       \bTR
         \bTH Chemical name \eTH
         \bTH Data \eTH
         \bTH Date \eTH
       \eTR
     \eTABLEhead
     \bTABLEbody
       \getbufferdata[ChemicalTable]
     \eTABLEbody
   \eTABLE}

\starttext

\startChemicalTable
  \bTR
    \bTD XXX \eTD
    \bTD YYY \eTD
    \bTD ZZZ \eTD
 \eTR
\stopChemicalTable

\stoptext

The layout for the table should be as Aditya told better be moved into a setups block which can then be loaded with the \bTABLE command.

\startsetups[ChemicalTable]
    \setupTABLE[start][frame=off]
\stopsetups

\def\stopChemicalTable
  {\bTABLE[setups=ChemicalTable]
     ...
   \eTABLE}
  • Thanks for the help. I'm still coming to grips with ConTeXt. – dreamlax Dec 10 '15 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.