3

To insert figures in LaTeX document I use this code repeatedly:

%%%%%%%%%%%%%%%%%%%%%%%%%%% figure environment start %%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[hb!]
\centering
\includegraphics [scale=0.35]{images/fig1.eps}
\caption{mycaption.}
\label{fig:fig1}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure environment end %%%%%%%%%%%%%%%%%%%%%%%%%%%%

Is there any way i can make macro of this code block and create a keyboard shortcut such as CTRL+Shift+f that automatically insert this code.

Or, could we write a snippet and so that i can insert this code block in KILE text editor. I know how to make template in kile but what I need is shortcut key that inserts this piece of code automatically.

Maybe I can create a simple text file somewhere in kile directory and use it. But I don't know how to do this.

Any suggestions will be greatly appreciated!
Related links:

1
  • Welcome! Since you already saw the questions concerning snippets, could you explain the problem? Why can't you just define the snippet and assign it a shortcut? That works fine for me.
    – cfr
    Commented Apr 12, 2016 at 19:38

2 Answers 2

3

Start selecting the desired text in a Kile document:

highlighted text

Keeping the text selected, choose Tools > Create Snippet from the menu to bring up the snippet creation dialogue:

create snippet

This allows you to specify the keyboard shortcut and other options of your choice.

Alternatively, choose Tools > Snippets... to create a snippet without basing it on text in the current document. In this case, you can just type the text from scratch into the dialogue box.

Tools > Snippets... also allows you to edit and manage existing snippets.

2
  • Thanks a lot! A small followup question, if i open a blank tex file in kile, can i insert previously defined templates into it. I know if i want a new template we can use those from kile but i don't know how to insert old templates into a new blank file? Commented Apr 13, 2016 at 13:57
  • Why don't you just select the relevant template rather than a blank one when you create the new file?
    – cfr
    Commented Apr 13, 2016 at 18:02
0

This question is quite old and I could not find the Create Snippet windows suggested in this answer. Still, in Kyle version 2.9, one can use User Tags, as suggested here. They can be found in the menu there:

LaTeX -> User-Tags -> Edit User Tags

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .