1

I've been reading the documentation and some other previous questions but I don't find what I am doing bad in my definition of the newcolumntype A in order not to write a double & when writing the columns in the array.

\documentclass{amsart}

\usepackage{amsthm}
\usepackage[main=spanish]{babel}
\usepackage{array}

\theoremstyle{definition} \newtheorem{ejercicio}{Ejercicio}

\newcolumntype{A}{>{\ado~}r}

\newcounter{ado}[ejercicio]
\newcommand*{\ado}
 {\stepcounter{ado} \makebox[2em][r]{\alph{ado}})~}

\begin{document}

\begin{ejercicio} Un ejercicio. %this one has the desired aspect
\[
\begin{array}{rlrlrl}
\ado & 2^1= & \ado & 2^2= & \ado & 2^3= 
\end{array}
\]
\end{ejercicio}

\begin{ejercicio} Otro ejercicio. %the one to be fixed
\[
\begin{array}{AlAlAl}
2^1= && 2^2= && 2^3=
\end{array}
\]
\end{ejercicio}

\end{document}

1 Answer 1

2

Let's have a look on your definition of the columntype A:

\newcolumntype{A}{>{\ado~}r}

The effect is: Put a right-aligned column (r) and at the user-defined command \ado to the beginning of it (>{\ado}). Which means that you create a column with text that you can insert into this cell.

In the definition of your array, you use AlAlAl meaning: You have first a right-aligned column with the extra text added to it, then a left-aligned column without extra text, and these two three times. But what you actually want to do is to have only one column and extra text.

So there are two possible solutions:

  • Remove the r from the definition of A, and then use AlAlAl.
  • Keep this definition of A, but use AAA only.

This example shows both ways, but defines the second way as B:

\documentclass{amsart}

\usepackage{amsthm}
\usepackage[main=spanish]{babel}
\usepackage{array}

\theoremstyle{definition}
\newtheorem{ejercicio}{Ejercicio}

\newcolumntype{A}{>{\ado~}}
\newcolumntype{B}{>{\ado~}r}

\newcounter{ado}[ejercicio]
\newcommand*{\ado}{\stepcounter{ado}\makebox[2em][r]{\alph{ado}})~}

\begin{document}

\begin{ejercicio} Un ejercicio.
\[
\begin{array}{rlrlrl}
\ado & 2^1= & \ado & 2^2= & \ado & 2^3= 
\end{array}
\]
\end{ejercicio}

\begin{ejercicio} Otro ejercicio.
\[
\begin{array}{AlAlAl}
2^1= & 2^2= & 2^3=
\end{array}
\]
\end{ejercicio}

\begin{ejercicio} Tertio ejercicio.
\[
\begin{array}{BBB}
2^1= & 2^2= & 2^3=
\end{array}
\]
\end{ejercicio}

\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 .