Can LaTex Define Typographic Functions Similar to Postscript?

  • Context: LaTeX 
  • Thread starter Thread starter Stephen Tashi
  • Start date Start date
  • Tags Tags
    Functions Latex
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
Does LaTex have the ability to define typographic functions, in a manner similar to the way Postscript can? I've only studied LaTex by following examples and I haven't seen any with that degree of sophistication.

I'm not talking about whether one can write things like [itex]\sin{x}[/itex]. As an example of what I mean, can you could write a function (or "macro") to represent a 3x3 matrix in terms of a letter that you would input. So matrix-macro(a) would give

\begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{bmatrix}

and matrix_macro(b) would give

\begin{bmatrix} b_{11} & b_{12} & b_{13}\\ b_{21} & b_{22} & b_{23} \\ b_{31} & b_{32} & b_{33} \end{bmatrix}
 
Physics news on Phys.org
Yes it does. Look up the \newcommand macro. Most "serious" tutorials on how to typeset math in LaTeX will have lots of examples.

You can't use "underscore" in your function names, but you could write something like
Code:
\newcommand{\mymatrix}[1]%
{\begin{bmatrix} #1_{11} & #1_{12} & #1_{13} \\ #1_{21} & #1_{22} & #1_{23} \\
#1_{31} & #1_{32} & #1_{33} \end{bmatrix}}

\begin{document}

$$\mymatrix{a}$$
$$\mymatrix{b}$$

\end{document}

In fact most "commands" in LaTeX (e.g. \bmatrix) are defined in this way, and if you don't like exactly what they do, you can change them.
 
I'd also point out that TeX is Turing-complete.