LaTeX Can LaTex Define Typographic Functions Similar to Postscript?

  • Thread starter Thread starter Stephen Tashi
  • Start date Start date
  • Tags Tags
    Functions Latex
Click For Summary
LaTeX can define typographic functions similar to Postscript using the \newcommand macro, allowing users to create custom commands for complex structures like matrices. For instance, a user can define a matrix macro that takes a letter as input and generates a corresponding matrix format. While underscores cannot be used in function names, alternative naming conventions can be employed. Most advanced LaTeX tutorials provide examples of such customizations. Overall, LaTeX's flexibility and Turing-completeness enable sophisticated typographic definitions.
Stephen Tashi
Science Advisor
Homework Helper
Education Advisor
Messages
7,864
Reaction score
1,602
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 \sin{x}. 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.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 2 ·
Replies
2
Views
987
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
1K
Replies
6
Views
2K