 	    (setq comment (read-file comment-file-name))
 	  (setq comment "[no comment specified]"))
 
+	 ; determine the file name that is to be used as a reference name
+         (setq cur-reference-name (concat cur-lastpath "/" (file-name-sans-extension cur-file)))
+
 	(insert cur-file)
 	(insert (make-string 4 ?\t))
 	(insert comment)
 	
 	; append the current file to the file table
 	; line-number, full path to file, contents of comments file
-	(setq file-table (cons `(,(line-number-at-pos) ,(concat (file-name-as-directory cur-dirname) cur-file) ,comment) file-table))
+	(setq file-table (cons `(,(line-number-at-pos) ,(concat (file-name-as-directory cur-dirname) cur-file) ,cur-reference-name ,comment) file-table))
 	(if (> (length cur-files) 0)
 	    (insert "\n")))
 	(beginning-of-line) ; looks nicer)


  (interactive "p")

;  (message file-table)
  (use-local-map rc-menu-mode-map))

;;;###autoload

  (interactive)
  (setq fileinfo-to-insert (current-menu-entry))
  (setq filename (car fileinfo-to-insert))
  (setq reference-name (car (cdr fileinfo-to-insert)))
  (setq comment (car (last fileinfo-to-insert)))
  (switch-to-buffer (other-buffer))
  (insert-org-image filename comment reference-name))


(defun current-menu-entry ()
