Jump to content

Creating a newcommand for giving tilde (~) in LaTeX

Hi all,

I want to write symbols with tilde (~) on their head. The general command for this is 

\tilde(a)

Now I can define a shortcut if I am using it multiple times. The standard way to do it is to include a line 

\renewcommand{\t}[1]{\tilde{#1}}

in the preamble. Then 

\t{a}

will give me the same result. However I don't want to use the curly braces. What I want is that 

\ta

give the same result as  

\renewcommand{\t}[1]{\tilde{#1}}

 

I can do renewcommand/newcommand for individual alphabets but was wondering whether I could write a single command that does the same.

 

Does anyone know how to do it?

Thanks

Link to comment
Share on other sites

Link to post
Share on other sites

22 minutes ago, tobeornottobealttfan said:

will give me the same result. However I don't want to use the curly braces. What I want is that 

\ta

give the same result as  

\renewcommand{\t}[1]{\tilde{#1}}

 

As far as I know this is not possible, as the interpreter wil interpret it as the command "ta".

 

What you are looking for may partially already exist, however, as LaTeX offers shortcuts for diacritics for normal text:

\"o -> gives ö
\~a -> gives ã
\`e -> gives è
\'i -> gives í
\^u -> gives û

Extending this to random symbols I don't think is possible without the curly brackets, as it needs a way to distinguish the command from the argument. For symbols it may help that you (likely) have another backslash, but for normal letters how will it distinguish between \ta (the command \ta) and \ta (the command \t with argument a)?

Crystal: CPU: i7 7700K | Motherboard: Asus ROG Strix Z270F | RAM: GSkill 16 GB@3200MHz | GPU: Nvidia GTX 1080 Ti FE | Case: Corsair Crystal 570X (black) | PSU: EVGA Supernova G2 1000W | Monitor: Asus VG248QE 24"

Laptop: Dell XPS 13 9370 | CPU: i5 10510U | RAM: 16 GB

Server: CPU: i5 4690k | RAM: 16 GB | Case: Corsair Graphite 760T White | Storage: 19 TB

Link to comment
Share on other sites

Link to post
Share on other sites

35 minutes ago, tikker said:

 

Extending this to random symbols I don't think is possible without the curly brackets, as it needs a way to distinguish the command from the argument. For symbols it may help that you (likely) have another backslash, but for normal letters how will it distinguish between \ta (the command \ta) and \ta (the command \t with argument a)?

I see.
This makes sense.

 

Thanks for this.

36 minutes ago, tikker said:
\"o -> gives ö
\~a -> gives ã
\`e -> gives è
\'i -> gives í
\^u -> gives û

 

Link to comment
Share on other sites

Link to post
Share on other sites

46 minutes ago, tikker said:

 

\"o -> gives ö
\~a -> gives ã
\`e -> gives è
\'i -> gives í
\^u -> gives û

However, I can't seem to make it work in mathmode. Any ideas for that?

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, tobeornottobealttfan said:

However, I can't seem to make it work in mathmode. Any ideas for that?

In math mode you can use

\text{\"o}

or

\mathrm{\"o}

Use the latter if you want normal text, the former if you still want it printed in "math style".

 

Crystal: CPU: i7 7700K | Motherboard: Asus ROG Strix Z270F | RAM: GSkill 16 GB@3200MHz | GPU: Nvidia GTX 1080 Ti FE | Case: Corsair Crystal 570X (black) | PSU: EVGA Supernova G2 1000W | Monitor: Asus VG248QE 24"

Laptop: Dell XPS 13 9370 | CPU: i5 10510U | RAM: 16 GB

Server: CPU: i5 4690k | RAM: 16 GB | Case: Corsair Graphite 760T White | Storage: 19 TB

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×