Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I try to create a custom env, based on a tabular. I try to make a \begin{center} before my tabular to remove identation at the beginning of the tabular, but he tells me

"File ended while scanning use of \TX@get@body"

If i remove begin center, it works...

I knew there is some trick to do, as doc said it at §5, they talk about tokens, token register, expandable token, first token and \relax, but it definitively not relaxed me. More seriously, I'm a real noob with latex, and if someone can tell me what I should do for running my tab in a centered environment in my custom env, he will be soo cool!

This is my MWE:

\documentclass{article}
\usepackage{fontspec}

\usepackage{tabularx}

\newenvironment{ffig}{ \begin{center} \tabularx{\linewidth}{|X|X|} }{   \endtabularx \end{center} }


\begin{document}

\begin{ffig}
\hline

voila un beau texte qui sert à rien & ah ben en voila encore un beau tiens  jvais mettre une belle virgule attention la voila, et hop un ptit point.
    \tabularnewline\hline 
          La liberté consiste à pouvoir faire tout ce qui ne nuit pas à autrui : 
      ainsi, l'exercice des droits naturels de chaque homme n'a de bornes que 
      celles qui assurent aux autres Membres de la Société la jouissance de ces 
      mêmes droits. Ces bornes ne peuvent être déterminées que par la Loi. 
          \tabularnewline\hline 
\end{ffig}


\end{document}
share|improve this question
1  
Welcome to TeX.sx! It does work for me, if I change the center environment in their macro form too, i.e. \center and \endcenter instead of \begin{center} and \end{center} respectively. (The second row also misses a &.) –  Qrrbrbirlbel Feb 28 '13 at 1:50
    
Ok, it worked with \center, thx :) –  user26622 Feb 28 '13 at 21:21
add comment

1 Answer

Use also the macro form of the center environment, i.e. \center and \endcenter.

(I also added a missing & in the second line so that the last vertical line is drawn again.)

Code

\documentclass{article}
\usepackage{fontspec}
\usepackage{tabularx}

\newenvironment{ffig}{%
    \center
    \tabularx{\linewidth}{|X|X|}%
}{%
    \endtabularx
    \endcenter
}

\begin{document}
\begin{ffig}
    \hline
    voila un beau texte qui sert à rien &
    ah ben en voila encore un beau tiens jvais mettre une belle virgule attention
      la voila, et hop un ptit point. \\ \hline
    La liberté consiste à pouvoir faire tout ce qui ne nuit pas à autrui :
      ainsi, l'exercice des droits naturels de chaque homme n'a de bornes
      que celles qui assurent aux autres Membres de la Société la jouissance
      de ces mêmes droits. Ces bornes ne peuvent être déterminées que par la Loi. &
    \\ \hline
\end{ffig}
\end{document}

Output

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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