Text FormattingCreate an array macro

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
danielvelizv
Posts: 45
Joined: Wed May 25, 2016 7:04 am

Create an array macro

Post by danielvelizv »

I need to create a macro with array environment that contents 3 columns and all its elements are \displaystyle ones, something I can use repeatedly throughout a document. Any idea to do that?

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Create an array macro

Post by Stefan Kottwitz »

Here's an example:

Code: Select all

% in the preamble:
\usepackage{multienum}
\settowidth{\labelwidth}{\textbf{1.99)}}
...
\begin{multienumerate}
\everymath{\displaystyle}
\renewcommand{\labelenumi}{\addtocounter{multienumi}{1}\textbf{1.\arabic{multienumi})}}
\mitemxxx
  {$\int 2x - 3x^2\,dx$}
  {$\int 2x - 3x^2\,dx$}
  {$\int x^{3/2} + 2x + 1\,dx$}
\mitemxxx
  {$\int \frac{\sqrt{5x}}{5} + \frac{5}{\sqrt{5x}}\,dx$}
  {$\int (2t^2 - 1)^2\,dt$}
  {$\int 2 \sen x + 3 \cos x\,dx$}
\end{multienumerate}
multiple-item-list.png
multiple-item-list.png (10.31 KiB) Viewed 4020 times
Stefan
LaTeX.org admin
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Create an array macro

Post by cgnieder »

Another idea:

Code: Select all

\documentclass{article}

\usepackage{tasks}

\begin{document}

\begin{tasks}[item-format=\everymath{\displaystyle}](3)
  \task $\int 2x - 3x^2\,dx$
  \task $\int 2x - 3x^2\,dx$
  \task $\int x^{3/2} + 2x + 1\,dx$
  \task $\int \frac{\sqrt{5x}}{5} + \frac{5}{\sqrt{5x}}\,dx$ 
  \task $\int (2t^2 - 1)^2\,dt$
  \task $\int 2 \sin x + 3 \cos x\,dx$
\end{tasks}

\end{document}
tasks.png
tasks.png (10.06 KiB) Viewed 3971 times
Regards
site moderator & package author
Post Reply