emacs org mod with math expression - emacs

I am using org-mod to take note of some of my work, I have recently switched from sublime where I was used to writing some mathjax snippet.
What would be the correct and easiest way of having this snippet rendered correctly (either in the buffer or if not possible, via C-c C-c or C-c C-e).
\hat{y} = \hat{\beta}_{0}+\hat{\beta}_{1}x_{1}+\hat{\beta}_{2}x_{2}+...+\hat{\beta}_{p}x_{p}
ps : in my .emacs conf file I don't have anything closely related to mathjax or Latex.
Kr,

Enclose the latex fragment in \( ... \) or \[ ... \]and do C-c C-x C-l (bound to org-toggle-latex-fragment). See the doc string of this function for argument usage.
In recent versions of org, you customize org-preview-latex-default-process to set it to the value of the backend you want. You need either dvipng, dvisvgm or ImageMagick as the backend. See also the doc string of the variable org-preview-latex-process-alist: it might help explain some things, although you don't have to do anything with it.
If these variables don't exist, you might be using an earlier version of org where the setup is different. If that's the case, then please post which version you are using: M-x org-version would tell you.
EDIT: in earlier versions, the function is called org-preview-latex-fragment and it's not bound to a key by default. You can call it with M-x org-preview-latex-fragment and you can get rid of the preview with C-c C-c. The backend setup is different as well: there is support for dvipng and ImageMagick only and the variables are different.

Related

Change default drag-and-drop behavior to open file in read-only mode

I just finished the Emacs Lisp intro and am getting my feet wet with customization. I've browsed the Emacs FAQ, the Emacs W32 FAQ, and perused the fine manual for drag and drop information. I am using GNU Emacs 24.5.1 for Windows without Cygwin (etc.).
I would like to update the default drag and drop behavior to open such files in read only mode. Through C-h f I've identified the dnd functions. In particular, dnd-open-file may be relevant. By C-h k and then dragging a file into Emacs, I've identified the function w32-drag-n-drop. Also, within the Reference Manual is a section on drag-and-drop which specifies x-dnd-types-alist.
How do I identify which of these items, if any, needs to be modified?
What is a safe way to modify its behavior?
I cannot find documentation on x-dnd-types-alist. Is it a function? A variable?
Is there a resource I've overlooked which I should be looking at?
Partial answers of a general nature - I can't help with your dnd problems,
but I hope these suggestions will be of some use.
Q2. It's a good idea to have a minimal init file, containing whatever is necessary to initialize an environment for testing. You can them invoke emacs like this:
emacs -q -l /path/to/minimal/init/file
bypassing your initialization file (-q) and loading the minimal init file instead. Then if something blows up, you just kill this emacs instance, and start again (possibly with a modified init file).
Q3. It's a variable (as are all alists). An alist (short for association list) is a list of key-value pairs. You can get the docstring of any variable with
C-h v VARNAME RET
e.g.
C-h v x-dnd-types-alist RET
Q4. If all else fails, the source is available...

call emacs commande automatically

I would find a way to execute the commands in the file emacs. Emacs and therefore automatically.
For example I often use: highlight-80
So I'm forced to type every time: Meta key + highlight-80 +-fashion
it's the same with linum-mode and plenty of other.
I have been trying to put in the file emacs.:
(highlight-80 +-mode)
But the option is not enabled.
Thank you in advance for your help. I am looking desperately for a moment, emacs is my working tool quotidient.
Regards
Use C-h f or C-h v, and read the Emacs manual about such choices.
Some of them are user options (variables), whose values you can customize, using M-x customize-option, so the default setting becomes what you want.
Others are modes, which you can call/set in your init file (~/.emacs) --- see the Emacs manual for how to do that. Typically, you use a positive number to turn a mode on and a negative number to turn it off. E.g.: (menu-bar-mode -1) in your init file turns off the use of a menu bar.
In sum, the Emacs manual (C-x r) is your friend. Sit down and have a first chat with it.
You seem generally a bit unsure about how customising Emacs works, so reading the manual on this topic should probably be your next step:
http://www.gnu.org/software/emacs/manual/html_node/emacs/Customization.html
If you are not using the current stable release (Emacs 24.3 at the moment), there's a chance that some of that information will not apply. The in-built manual is, of course, always correct for the version you are running:
C-hig (emacs) Customization RET

Emacs C-c } command and parentheses-match checking

I am working in Emacs 23, editing LaTeX via AUCTeX. I noticed in emacs that when I press C-c }, I receive the minibuffer message
Scan error: "Unbalanced parentheses", 16026, 16440
Question 1. What exactly is this command doing?
Question(s) 2. More generally, how can I determine what I a given macro is doing? Is there, for example, a universal command that request the keyboard shortcut as an input and outputs a description of the command to which that shortcut is bound? Is there a list of all active keyboard shortcuts?
Question 3. How can I find my unmatched parentheses? The post here recommends the command M-x check-parens, but it availed me nothing, not even a minibuffer message.
The answer to 1 and 2 is to do C-h k C-c } and see what the help buffer tells you. This is one of the features that allows us to call Emacs a self-documenting editor. Don't forget that you can follow the links in the help buffer to both the source code where this function is implemented and to other documentation.
You may also want to use C-h m to see all the key bindings added by the major and minor modes that are currently enabled and C-h ? to see what other interesting help functions there are.
I've never used check-parens specifically, but it does work in my current buffer, which is javascript. I see from its documentation (C-h f check-parens) that it relies on the current syntax table, so perhaps for TeX the syntax table doesn't contain enough information for check-syntax to find the error.

the "org-preview-latex-fragment" command in emacs org-mode

5here is a command named org-preview-latex-fragment in org-mode. its default binding key is C-c C-x C-l. In the org manual, it says this command could preview a latex fragment inline. but after using it, nothing is produced but blank frames (I can't upload images, sorry).
What happened? I'm using emacs23.1 on Ubuntu10.10, the org-mode version is 6.21b, and I've installed dvipng version 1.13-1.
I tried trace the code, but got lost. How can I fix this?
The easiest way to debug is to try to compile the temporary file created to create the fragment. It is usually located in /tmp and contains orgtex in the filename. You can find the exact name in Emacs's *Messages* buffer.
I resolve the problem by changing the program to convert latex fragment from dvipng to imagemagik.
I guess something is missing on my computer.
\M-x customize-variable RET org-latex-create-formula-image-program \RET
Update:
you can event increase the preview size by doing
\M-x customize-variable RET Org Format Latex Options RET
Update 2
I had some problem with imagemagick Have a look at the and switch back to dvipng after following the instruction in the doc. So both work correclty.

Emacs: Enter commands like in gedit

in gedit it's possible to define so-called "snippets" for simpler input.
For example, there is a snippet while. This means: If you type while -> (-> stands for tab key). And gedit automatically converts it to the following (including correct indentation):
while (condition){
}
In vim (in conjunction with latex-suite) I saw the following: If you type (, vim inserts just a (. If you type ( a second time, vim automatically converts it to \left( \right).
I found abbrev-mode but this mode doesn't place the cursor properly (i.e. between parentheses or inside the while loop).
I managed to create custom emacs keybindings/macros that do just the same (without having to press the tab key), so I know it's possible.
However, is there already and package where you can define such "snippets" without much effort? Or are there even any serious reasons not to use such things?
See yasnippet. It provides snippets for most major languages, and it is easy to add new ones or modify the old ones.
Yes, yasnippet is probably the way to go. But make sure you learn the major mode you're using for your editing - when writing in LaTeX, learn auctex. Major modes can contain functionality that makes some snippets pointless, and do the same thing even better. So instead of using a begin/end-snippet in a LaTeX buffer, try C-c C-e in auctex. Etc :)
Don't forget abbrev-mode.