LaTeX is a macro package implemented on Donald Knuth's TeX programming language and is used primarily for creating high quality written documents. The underlying TeX system is Turing complete and LaTeX inherits this property, making it possible (but rarely advisable) to perform arbitrary computations in LaTeX; more interestingly it makes it possible to get any layout scheme you can describe precisely.
The Stack Exchange site dedicated to LaTeX is tex.stackexchange.com, which is probably a better place to ask any LaTeX-related questions than here on Writers. The other site also covers TeX and other related technologies.
A great many problems can be solved by selecting the right existing macro package from CTAN.