Changes

Jump to navigation Jump to search
6,429 bytes added ,  12:55, 27 April 2017
m
Changed snippet details
(updated 2017/03)
== Step 1: Install / Update '''ConTeXt''' == Installation and update of ConTeXt work the same way. If you only want to update ConTeXt you can start directly from point 3.
1. [http://standalone.contextgarden.net/setup/ Download] ConTeXt.
* You might want to change the name of the extracted directory to a shorter one as it will be the final location for ConTeXt.
3. Start your Windows command prompt.
* Use can start it by using the key shortcut <code>Windows-Key + R</code>, entering <code>cmd</code> and pressing <code>ENTER</code>-key.
* Alternatively you can use <code>Start</code> -> <code>Programs</code> -> <code>Accessories</code> -> <code>Command Pompt</code>
43. Navigate Install / Update ConTeXt  3. Method 1: Write a batch file Since at this point the installation and update of ConTeXt work the same way, the most effective solution is to create a batch file. To do so * use Windows Explorer to navigate to your ConTeXt directory. In there should be a file called <code>first-setup.bat</code>.* Use Windows Notepad or <code>Right-click</code> -> '''New''' -> '''Textfile''' to where create such.* If you extracted only want ConTeXt mkiv (highly '''recommended'''), add the ConTeXt archivefollowing line to the new and empty textfile: first-setup -engine=luatex -modules=all* Save the file as a '''batch'''-file and name it something like <code>update.bat</code>.* The easiest way * '''Note''' that the document ending has to be <code>.bat</code> not <code>.txt</code> or anything else. You might have to do so rename the file ending by hand.* Execute the batch file you just created by double-clicking on it. A command prompt window should pop up.** If it appears for only a few seconds, chances are high that the download server is down. In that case you might want tore-try the procedure at some other time.* Wait for the download / update to finish. After it is done, the command window should disappear by itself.** ConTeXt's folder's size should be around 380 - 400 MB when everything worked fine.  3. Method 2:Type the command by hand ** use Use Windows Explorer to navigate to your ConTeXt directory,.** click in Click into the upper white field with where the current locationis displayed.** enter Enter <code>cmd</code> and press <code>Enter</code>-key.
** Now Windows command prompt should pop up with the correct location.
* Otherwise do it you can start your Windows command prompt like this:** by using the old fashioned waykey shortcut <code>Windows-key + R</code>, entering <code>cmd</code> and pressing <code>Enter</code>-key. Some DOS commands you might need:** Alternatively you can use <code>Start</code> -> <code>Programs</code> -> <code>Accessories</code>X:-> <code>Command Pompt</code> change to drive X.* Some DOS commands you might need:
** <code>dir</code> list the content of the current directory
** <code>cd DIRECTORY</code> change to directory with name DIRECTORY
** <code>cd..</code> change to superior directory
** <code>cd\</code> change to drive root ** <code>X:</code> change to driveX:** also possible: <code>cd directory\subdirectory\subsubdir...</code>* Now In the end your command prompt should look like this:
X:\ConTeXt>_
* If you only want ConTeXt mkiv (highly '''recommended'''), enter the following line and press <code>Enter</code>-key:
first-setup -engine=luatex -modules=all
* Wait until the download / update is complete. Afterwards you can close the command prompt by entering <code>exit</code> and pressing <code>Enter</code>-key or by simply closing the window.
 
== Step 2: Add ConTeXt's executables folder to Windows search Path ==
 
'''Note''': you will need admin rights for this. On public machines for example you most probably won't be able to add ConTeXt to that machine's path. In that case skip this step and go to Step 3 respectively Step 4.1 directly.
 
1. Open Windows' '''System''' dialog
* either by <code>Right-click</code>ing on '''This PC''' / '''My Computer''' on your Desktop and then clicking on '''Properties'''
* or by clicking '''Start''' -> '''Settings''' -> '''About''' -> '''System Info'''
* or on older Windows Machines by going to '''Control Panel''' -> '''System'''.
 
2. Click on '''Advanced System Settings''' ("System Properties").
 
3. Click on '''Advanced'''-Tab.
 
4. Click on '''Environment Variables...'''.
 
5. Choose where to add ConTeXt's executables folder to:
*Either to '''User variables for USER''' for the current user only
*or to '''System variables''' for all users.
 
6. Double-click on the respective variable called Path.
57. Enter Add your ConTeXt executables to Windows path.* '''Note''' that the position, to where you add the following line:location is sorted by importancy. The most important directories will be searched first. This might be taken into account when using ConTeXt together with MiKTeX for example. It's safest to place ConTeXt's path at the very beginning.* If In '''User''' Path variable you only want ConTeXt mkiv might need to add the location and seperate it from the existing ones by using a semikolon (highly <code>;</code>).* In '''recommendedSystem''')Path variable you probably only have to add a new line. The location should look like this: * Win x86 / 32 bit: firstX:\ConTeXt\tex\texmf-setup mswin\bin* Win x64 / 64 bit: X:\ConTeXt\tex\texmf-engine=luatex win64\bin 8. Save your changes. Usually no restart or re-modules=alllogin is needed after this operation, but to make sure, that the folder was added, you should restart your machine.
6. Wait until Optional: You can test whether it worked by starting your Command prompt and entering the download is completefollowing line, while being in a directory other than the one you just added.
== Step 2: Add ConTeXt's executables folder to Windows search PATH == context -version
work in progress* A message with ConTeXt's version number should apear.* If a message like '''context' is not recognized as an internal or external command...'' appears, you should restart your machine, make sure that you added the correct location or re-try the operation by starting from Step 2.1.
== Step 3: Install '''Textadept''' ==
1. [https://foicica.com/textadept/download/textadept_LATEST.win32.zip Download] and extract [https://foicica.com/textadept/ '''Textadept'''] to a folder of your choice.
2. Use <code>textadept.exe</code> from the extracted folder to start '''Textadept'''.
== Step 4: Tweak '''Textadept''''s settings ==
1. Use your freshly installed Textadept '''Note''' that almost all changes to open Textadept's main configuration are saved in the file called <code>init.lua</code>.There is two of them, of which you should edit only one: * After extraction One of the downloaded Textadept archive there them is a file called <code>init.lua</code> in the extracted Textadept main program folder. It is '''not recommended''' to edit this file as your changes will be lost when you update Textadept. Instead:* When you start Textadept for the first time , a new folder <code>SYSDRIVE:\users\USERNAME\.textadept</code> gets created. It also contains the a file called <code>init.lua</code>. It's This is the file and location where you should save all your Textadept settings. This way you can make a copy and use it on several computers. When you open it for the first time it should be empty. Usually you have to restart Textadept after changing its configuration files. Robert Gieseke created a code though, which you can add to your <code>init.lua</code> to circumvent having to restart Textadept, whenever a change is made:  -- Save and reset Lua state: `F9` keys['f9'] = function() -- Mac OSX users might prefer: keys[OSX and 'mf9' or 'f9'] io.save_file() reset() end Save <code>init.lua</code> and restart Textadept once. After doing so you can add changes to Textadept's configuration files and press <code>F9</code>-key afterwards to save and reload the changes without having to restart Textadept. === Step 4.1: Bind a PDF build command into Textadept === 1. Use Textadept to open your <code>init.lua</code> stored in <code>SYSDRIVE:\users\USER\.textadept\</code>.
2. Add an execute command for ConTeXt to Textadept's menu:
* If your ConTeXt executables folder is already in the Windows search PATHPath:
textadept.run.compile_commands.tex = 'mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
* If for some reason you can't add the folder to PATH , for example on public machines, you have to add the full path to your ConTeXt executables. For example:
textadept.run.compile_commands.tex = 'C:/ctx/tex/texmf-mswin/bin/mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
* '''Important''': you have to start `first-setup.bat` from the main ConTeXt directory every time you restart a machine, on which ConTeXt is not in the Windows search path (see Step 1.3), otherwise you will get ''file not found''-errors, when trying to compile a ConTeXt document.
* '''Note''' that you have to use slash <code>/</code> instead of backslash <code>\</code> in the file path, since Lua (same as ConTeXt) interprets a <code>\</code> as the beginning of a command, while for Windows it doesn't make any difference.
6. When you have a popular PDF reader installed already, it should pop up at the end of the process and show the created PDF output. [https://www.sumatrapdfreader.org/free-pdf-reader.html '''Sumatra PDF'''] is highly recommended for this.
== Optional= Step 4.2: Additional '''Textadept''' tweaks Lexing (command highlighting & code folding) ===
=== Lexing ===A lexer is a file that defines command highlighting and code folding keywords. Textadept comes with a ConTeXt lexer. In order to be able to use command highlighting and code folding when writing ConTeXt documents, you have to bind those documents to the lexer. To do so
A lexer is a file that defines command highlighting. Since Textadept comes with an own ConTeXt lexer, it is a good idea to bind <code>*.tex</code> files to Textadept's ConTeXt lexer. To do so: 1. Add add the following lines line to your <code>USER/.textadept/init.lua</code>and save it afterwards:
textadept.file_types.extensions.tex = 'context'
* If you plan to use LaTeX and ConTeXt, you should use different file extensions. For example <code>*.tex</code> for LaTeX and <code>*.cxd</code> for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to Textadept's ConTeXt lexer, since <code>.tex</code> files are automatically recognized as LaTeX documents:
3. Open a ConTeXt document and check Textadept's status bar in the lower right corner. It should say '''context'''. If it says '''latex''' make sure it really is a ConTeXt file or repeat the procedure.
 
== Optional: Additional '''Textadept''' tweaks ==
=== Themes & editor font changes ===
in which the expression '''dark''' is the filename of the theme located either in <code>Textadept\themes</code> or you can download and add new themes to <code>USER\.textadept\themes</code>
(create the folder if it's not there yet).
 * There are more settings which you can look up in Textadept's [https://foicica.com/textadept/manual.html#Themes online manual]. * Many ''base16'' themes for Textadept can be found at [https://github.com/rgieseke/textadept-themes Robert Gieseke's GitHub]. You can preview them [https://chriskempson.github.io/base16/ here] (partially).
=== Snippets ===
Snippets are predefined code or text blocks. Using snippets can save a lot of time as you won't have to retype often used commands and text passages. You add them snippets to your <code>USER/.textadept/init.lua</code>. Snippets in In Textadept they look like this:
-- The first line is mandatory:
snippets['context'] = snippets['context'] or {}
-- Snippets start here:
snippets.context['emph'] = '{\\em %<selected_text>%0}' snippets.context['bold'] = '{\\bf %<selected_text>%0}'
snippets.context['start'] = '\\start%1\n%0\n\\stop%1'
snippets.context['itemize'] = '\\startitemize\n\t%0\n\\stopitemize'
* The most important formatting commands are the following:
**<code>%0</code> creates a primary input ''closing'' caret (placeholder) (the cursor will jump here first'''last''')**<code>%1</code> creates one or multiple secondary input carets(1, 2, 3 and so on; you can also use the same integer multiple times: e.g. <code>\\start%1 ... \\stop%1</code>)**<code>%\n</code> creates a new line**<code>%\t</code> creates a tab**<code>%<selected_text></code> this is where highlighted text will be pasted when enclosing it with a snippet (e.g. <code>{\\emph %<selected_text>%0}</code>) * After adding snippets, you have to restart Textadept or reset Lua state as described in Step 4. * You can paste snippets into ConTeXt documents** either by typing the keyword that you defined within <code>snippets.context['KEYWORD']</code> and pressing <code>Tab</code>-key afterwards** or by using <code>Ctrl + K</code> (by default on Windows machines) to choose from the list of snippets. No matter in which order you add them to your <code>init.lua</code>, they will show up sorted alphabetically.
* After adding '''Note''' that since you added snippets.'''context''', you have i.e. to restart Textadept first's ConTeXt lexer, Textadept's status bar in the lower right corner has to say '''context''', otherwise use a ConTeXt document or see Step 4.2.
* Then you can use <code>Alt + K<Read more about snippets in Textadept's [https://foicica.com/code> (by default on Windows machines) to choose from the list of textadept/api.html#textadept.snippets, when a ConTeXt document is opened in the active tabmanual].
A ConTeXt module for textadept is being developed at [https://github.com/stephengaito/ta-context-latex ta-context-latex].
Note though, that if you plan to use Textadept without LaTeX with ConTeXt mkiv only (recommended), then you might not need the package mentioned above as it comes with literally only a hand full of ConTeXt snippets. Italso needs additional software to be installed (Textredux, ctags), so that it's almost more comfortable to create own ConTeXt snippets with the ease of Textadept (see above).
194

edits

Navigation menu