Generalusing renewcommand in longtable problem

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
tkach
Posts: 1
Joined: Sat Mar 19, 2011 3:04 pm

using renewcommand in longtable problem

Post by tkach »

Dear friends,
can anybody find a solution or tell me a right place to dig concerning the wollowing problem:
I am trying to make an environment for printing syncronized bilingual document using a longtable environment. The text needs to be enumerated.
The first level works basically OK (to test, comment all lines with marks (1) or (2)), but adding a second one (to test, uncomment lines marked (1) and comment those marked (2)) results in an error "ERROR: Extra }, or forgotten \endgroup.".

I tried to replace the macro for its meaning (to test, uncomment lines marked (2) and comment those marked (1)), which produced a strange result: item in left column prints with two-level label, but the labels near subsequent items are one-level. It seems, that renewcommand acts locally for a table cell?

Thank you,
Vladimir

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[english,russian]{babel}
\usepackage{amsmath}
\usepackage{fancyhdr}
\usepackage{longtable}
\usepackage{textcomp}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{ifthen}
\usepackage{geometry}

\newlength{\tctwidth}
\setlength{\tctwidth}{0.5\textwidth minus 0.2 cm}
\newlength{\tcti}
\setlength{\tcti}{3em}
\newlength{\tctii}
\setlength{\tctii}{2\tcti}
\newlength{\tctiii}
\setlength{\tctiii}{3\tcti}
\newlength{\tctiv}
\setlength{\tctiv}{4\tcti}
\newcounter{tctci}
\setcounter{tctci}{0}
\renewcommand*{\thetctci}{\arabic{tctci}}
\newcounter{tctcii}[tctci]
\renewcommand*{\thetctcii}{\arabic{tctcii}}
\newcounter{tctciii}[tctcii]
\renewcommand*{\thetctciii}{\arabic{tctciii}}
\newcounter{tctciv}[tctciii]
\renewcommand*{\thetctciv}{\roman{tctciv}}
\newcounter{tctd}
\setcounter{tctd}{0}
\newcommand*{\tctllng}{\Rus}
\newcommand*{\tctrlng}{\Eng}
\newcommand*{\tctnilab}{}
\newcommand*{\tctnplus}{}
% The environment
\newenvironment{tcte}
  {
  \addtocounter{tctd}{1}
  \ifthenelse{\equal{\value{tctd}}{1}} % New outer environment
    {
    \setcounter{tctci}{0}
    \refstepcounter{tctci}
    \renewcommand*{\tctnilab}{\thetctci.}
    \renewcommand*{\tctnplus}{\refstepcounter{tctci}}
    \begin{longtable}{p{\tctwidth}p{\tctwidth}}
    }
    {
    \ifthenelse{\equal{\value{tctd}}{2}} % Level 1 numbering
      {
      \setcounter{tctcii}{0}
      \refstepcounter{tctcii}
      \renewcommand*{\tctnilab}{\thetctci.\thetctcii.}
      \renewcommand*{\tctnplus}{\refstepcounter{tctcii}}
      }
      {
      }
    }
  }
  {
  \ifthenelse{\equal{\value{tctd}}{1}}
    {
    \end{longtable}
    \renewcommand*{\tctnilab}{}
    \renewcommand*{\tctnplus}{}
    }
    {
    \ifthenelse{\equal{\value{tctd}}{2}}
      {
      \renewcommand*{\tctnilab}{\thetctci.}
      \renewcommand*{\tctnplus}{\stepcounter{tctci}}
      }
      {
      }
    }
  \addtocounter{tctd}{-1}
  }

% eNumerated Item
\newcommand{\tctni}[2]{\tctllng \tctnilab #1 & \tctrlng \tctnilab #2\\ \tctnplus}

\begin{document}

\begin{tcte}
  \tctni{По-русски}{In english}
%  \begin{tcte} %(1)
  \setcounter{tctcii}{0} %(2)
  \refstepcounter{tctcii} %(2)
  \renewcommand*{\tctnilab}{\thetctci.\thetctcii.} %(2)
  \renewcommand*{\tctnplus}{\refstepcounter{tctcii}} %(2)
    \tctni{По-русски}{In english}
%  \end{tcte} %(1)
  \tctni{По-русски}{In english}
  \tctni{По-русски}{In english}
  \tctni{По-русски}{In english}
\end{tcte}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply