Terminology is the way to go to display images in terminal emulators. In ttys, the framebuffer is available too.
tex2im provides a nice solution to convert formulas as images but has drawbacks which may be problematic depending on your usecase. It puts an out.png file in your current directory, accept only math, etc.
Here is a similar but somewhat more customizable approach:
#!/bin/sh
dir=$(mktemp -d) || exit 1
cd $dir
cat <<EOF > file.tex
\\documentclass[varwidth=true,border=5pt]{standalone}
\\begin{document}
$1
\\end{document}
EOF
texfot --quiet --interactive pdflatex -shell-escape file.tex && \
convert -density 600 file.pdf -quality 90 -background white -alpha off -resize 50% file.png && \
tycat $dir/file.png && \
sleep 0.5
rm -r $dir
It uses the package standalone to produce a PDF the right size and then convert it with ImageMagick. Actually, standalone can handle the transformation but do not allow all the options ImageMagick accepts.
All the file are created in a temporary directory. It's necessary to wait a little before removing it in order not to race with tycat which displays the picture in the terminal.
Example of use:
