How to Write a Function in LaTeX (Not PF Version)?

  • Context: LaTeX 
  • Thread starter Thread starter quasar987
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary

Discussion Overview

The discussion revolves around writing functions in LaTeX, specifically focusing on achieving proper alignment of arrows in mathematical expressions. Participants explore various methods to ensure that the elements of the function notation align correctly, regardless of their lengths.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant inquires about how to write a function in LaTeX with arrows that are appropriately sized.
  • Another participant seeks clarification on what is meant by "just right in length."
  • A participant expresses a desire for a command that would automatically align the elements of the function notation with the corresponding sets, independent of their lengths.
  • One suggestion involves using the '&' character to align elements, similar to aligning equal signs in equations.
  • A participant points out that if the set A is long, it can lead to misalignment with the output f(a), suggesting a need for a command that automates this alignment.
  • Another participant proposes using the \phantom{} macro to create invisible objects that match the size of the long definitions to help with alignment.
  • One participant mentions that the amsmath align environment could be a solution for achieving the desired alignment.

Areas of Agreement / Disagreement

The discussion contains multiple competing views on how to achieve proper alignment in LaTeX functions, with no consensus reached on a single solution.

Contextual Notes

Participants express uncertainty about the best approach to align arrows and elements in LaTeX, indicating that different methods may depend on specific use cases or preferences.

quasar987
Science Advisor
Homework Helper
Gold Member
Messages
4,796
Reaction score
32
How would I go about to write in latex (not the PF version, the actual thing) a function? By that, I mean when you go

f:A\rightarrow B
a\mapsto f(a)

but how to write the code so that the arrows are all just right in length?

Thx!
 
Physics news on Phys.org
What do you meany by "just right in length"?
 
I am looking for a command, if it exist, that will make it so a and f(a) will automatically have the right alignment with A and B respectively, and this, independantly of what A,B,a and f(a) are.
 
Do you mean aligning the arrows like the equal signs are lined up here:

2vkbvb6.jpg


If so, simply surround whatever you want everything to align to with &'s. So for this, it was putting "&=&" to align all the equal signs.
 
No. For instance, if I take A to be very long, the formula will look ugly:

f:A set that's very long to write outtttt\rightarrow B
a\mapsto f(a)

Here, the problem is that f(a) is not aligned with B. I could fix this my making the mapsto arrow longer, but I was hoping for a command like \definefunction{f}{A}{B}{a}{f(a)} that would set everything right automarically.
 
Oh, I see what you mean: aligning the arrows would align all. That's clever, thanks :)
 
I'm not sure exactly what you are trying to do, but the \phantom{} macro works out what size its argument would be if it was typeset, and then creates an invisible object the same size. Maybe you could use that to extend your arrow using a \phantom copy of the long definition.

EDIT: simultaneous post with your #6 !
 
The amsmath align environment should work for that.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K