Can LaTex Define Typographic Functions Similar to Postscript?

In summary, LaTex does have the ability to define typographic functions, similar to Postscript. This includes the ability to write macros to represent matrices in terms of input letters. However, underscore cannot be used in function names, but there are ways to work around this. Additionally, many commands in LaTex are defined using this method and can be customized if desired. It is also worth noting that TeX is Turing-complete.
  • #1
Stephen Tashi
Science Advisor
7,861
1,598
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
  • #2
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.
 
  • #3
I'd also point out that TeX is Turing-complete.
 

1. What are functions in LaTex?

Functions in LaTex are predefined commands that allow you to perform specific actions, such as formatting text, inserting mathematical equations, and creating tables and figures. They are an essential part of the LaTex language and make it easier to write and format documents.

2. How do I use functions in LaTex?

To use functions in LaTex, you need to first include the package or library that contains the specific function you want to use. Then, you can simply call the function and provide any necessary arguments or parameters. It is important to follow the correct syntax for each function to ensure it works properly.

3. Are there different types of functions in LaTex?

Yes, there are various types of functions in LaTex. Some common types include text formatting functions, mathematical functions, table and figure functions, and bibliography functions. Each type serves a specific purpose and has its own set of commands and syntax.

4. Can I create my own functions in LaTex?

Yes, you can create your own functions in LaTex using the \newcommand or \renewcommand commands. These commands allow you to define your own custom functions and specify the desired behavior and output. This can be useful for frequently used commands or for personalizing your document formatting.

5. Are there any resources for learning more about functions in LaTex?

Yes, there are many online resources, tutorials, and guides available for learning more about functions in LaTex. The official LaTex documentation and community forums are great places to start. Additionally, there are many books and online courses that cover LaTex and its functions in detail.

Similar threads

  • Precalculus Mathematics Homework Help
Replies
16
Views
2K
  • Advanced Physics Homework Help
Replies
2
Views
648
  • Linear and Abstract Algebra
Replies
12
Views
2K
  • Advanced Physics Homework Help
Replies
7
Views
907
  • Calculus and Beyond Homework Help
Replies
11
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
3K
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
6
Views
891
  • Differential Equations
Replies
2
Views
1K
  • Other Physics Topics
Replies
6
Views
1K
Back
Top