Insert LaTeX Image

1. New Doom Emacs Version

(defun tex-screenshot ()
  "Take a screenshot into a time stamped unique-named file in the
same directory as the org-buffer and insert a link to this file."
  (interactive)
  (make-directory "images" :parents)
  (setq filename
        (concat
         (make-temp-name
          (concat (file-name-directory buffer-file-name) "images/") ) ".png"))
  (call-process "import" nil nil nil filename)
  (insert (concat "\\fig{" (file-name-sans-extension (file-name-nondirectory filename)) "}{30mm}{caption}{label}"))
  ;;(insert (concat "\\begin{figure}[h!]\n  \\centering\n  \\includegraphics[width=\\columnwidth, scale=1]{images/" (file-name-sans-extension (file-name-nondirectory filename)) "}\n  \\captionof{figure}{}\n  \\label{fig:}\n\\end{figure}"))
)

Extra: for org

(defun org-screenshot ()
  "Take a screenshot into a time stamped unique-named file in the
same directory as the org-buffer and insert a link to this file."
  (interactive)
  (make-directory "img" :parents)
  (setq filename
        (concat
         (make-temp-name
          (concat (file-name-directory buffer-file-name) "img/") ) ".png"))
  (call-process "import" nil nil nil filename)
  (insert (concat "[[file:images/" (file-name-nondirectory filename) "]]"))
)

2. Old Neovim Version

Yes, this can be vastly improved

map('i', '<C-d>', '<cmd>r!scrot -s -e \'mv $f ./images/ && /usr/bin/latexScrot $f\'<CR>', silent) -- Ctrl+D en insert para meter imágenes en LaTeX
map('i', '<C-f>', '<cmd>r!scrot -s -e \'mv $f ./images/ && /usr/bin/mdscrot $f\'<CR>', silent) -- Ctrl+D en insert para meter imágenes en Markdown

latexScrot:

#!/bin/sh
echo "\begin{figure}[H]"
echo "  \centering"
echo "  \includegraphics[width=150mm, scale=1]{$1}"
echo "  \caption{}"
echo "\end{figure}"

mdScrot:

You can guess