2

I try to create a new environment for a monotonously repeating tabular, which has one parameter. This must be at the end of the tabular. I tried this way:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[magyar]{babel}
\usepackage{amsthm}
\newenvironment{point}[1]
{
    \begin{tabular}{ @{}p{.4\textwidth}p{.4\textwidth}c@{} }
    \hline
}
{
    \hline
    \multicolumn{2}{r}{Summary}& #1 point
    \end{tabular}
}

but I got Illegal parameter number in definition of \endpoint. error. I can't figure out, why is it happen and how to solve it.

1
2

The arguments of an environment are only available in the definition of the start code. But you can use a macro to save the content of the argument.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[magyar]{babel}
\usepackage{amsthm}
\newcommand*\points{}% <- new macro
\newenvironment{point}[1]
{%
    \renewcommand*\points{#1}% <- save the argument
    \noindent
    \begin{tabular}{ @{}p{.4\textwidth}p{.4\textwidth}c@{} }
    \hline
}
{%
    \hline
    \multicolumn{2}{r}{Summary}& \points~point
    \end{tabular}%
}

\begin{document}
\begin{point}{5}
  x&x\\
  y&y\\
\end{point}
\end{document}

enter image description here

0

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