How do you know when to put "at" (or any other preposition) in front of an infinitive?
Is there a rule for when you would use at, for, til, på, etc. or does it just depend on the context?
Hmm, I had like to see an example, either of the english or danish translation in order to help you. However, to my knowledge only 'at' is used before an infinitiv (in danish also called at-form ('form' being the same as in english) - source: danish wiki search of infinitive).
Maybe the question is "when do you NOT need at"?
You don't need at/to after modal verbs (which are way down the tree) - in English, words like can, should, must. can see (not can to see), should go (not should to go), but want to see, want to go.
There are also prepositions and adverbs that require that include at, til and so on - "for at" + infinitive, "in order to" see/go etc.
Actually, most of the where "at" is in front of an infinitve, it's used like a "partikel". The English partikel is "to" and the German one is "zu", although partikler aren't used that much in German. In all three languages, they are also prepositions.
"At" is often used in front of an infinitve
This does not apply when it comes after a modal verb (e.g. "Thomas kan spise kage" meaning "Thomas can eat cake")
This usually applies when it comes after a finite verb form that is not conjugated from a modal verb (e.g. "Thomas ønsker at få kage" meaning "Thomas would like to have kage")
When the -ing form is used in English, the infinitve with "at" in front is normally used in Danish (e.g. "Thomas ser frem til at få kage" meaning "Thomas is looking forward to getting cake")
In English "to" as a preposition" is often omitted in front of "to" as a partikel*. This does not apply in Danish as "til at" doesn't sound as weird as "to to"
"(in order) to" = "for at"
"looking forward XXX-ing" = "se frem til at XXX"
"*" = my dictionary (ordbogen.com) does not have a translation at the time
I hope it helps!