Emacs: orgtbl support for LaTeX.

master
Pierre Neidhardt 2013-09-26 12:07:33 +02:00
parent cd6f28cdb4
commit 39e807c5fd
4 changed files with 56 additions and 13 deletions

View File

@ -214,8 +214,9 @@ properly escaped with double-quotes in case it has spaces."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; MACROS
(defun tex-itemize ()
"Append \\item to the beginning of the line. On region, append
(defun latex-itemize ()
"Prepend \\item to the beginning of the line if not already
there, otherwise insert it on next line. On region, append
\item to every line and surround the region by an `itemize'
environment. If bound to M-RET, you can then easily apply this
command on the paragraph at point with M-h M-RET."
@ -223,7 +224,12 @@ properly escaped with double-quotes in case it has spaces."
(save-excursion
(let (min max case-fold-search)
(if (not (region-active-p))
(progn
(if (string-match "\\item" (buffer-substring (line-beginning-position) (line-end-position)))
(progn
(goto-char (line-end-position))
(newline)
(insert "\\item "))
(goto-char (line-beginning-position))
(insert "\\item")
(just-one-space))
@ -240,7 +246,8 @@ properly escaped with double-quotes in case it has spaces."
(newline)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HOOK
;; HOOKS
(add-hook
'tex-mode-hook
(lambda ()
@ -250,5 +257,7 @@ properly escaped with double-quotes in case it has spaces."
(set (make-local-variable 'compilation-hide-window) t)
(set (make-local-variable 'use-hard-newlines) t)
(local-set-key (kbd "<f9>") 'tex-pdf-view)
(local-set-key (kbd "M-RET") 'tex-itemize)
(tex-set-compiler)))
(add-hook 'latex-mode-hook (lambda () (local-set-key (kbd "M-RET") 'latex-itemize)))
(add-hook 'latex-mode-hook 'turn-on-orgtbl)

View File

@ -22,7 +22,13 @@
%% Properties
\title{${1:Title}}
\author{${2:\textsc{P.~Neidhardt}}}
\author{${2:P.~\textsc{Neidhardt}}}
\makeatletter
\let\thetitle\@title
\let\theauthor\@author
\let\thedate\@date
\makeatother
%%=============================================================================
%% Aliases
@ -49,7 +55,19 @@
\renewcommand{\arraystretch}{1.4}
% \renewcommand{\familydefault}{\sfdefault}
% \usepackage{needspace}
%% Narrow items
\newlength{\wideitemsep}
\setlength{\wideitemsep}{.5\itemsep}
\addtolength{\wideitemsep}{-7pt}
\let\olditem\item
\renewcommand{\item}{\setlength{\itemsep}{\wideitemsep}\olditem}
%% Header
% \usepackage{fancyhdr}
% \setlength{\headheight}{15.2pt}
% \pagestyle{fancy}
% \lhead{\thetitle}
% \rhead{\theauthor}
%%==============================================================================
%% Tables
@ -74,6 +92,9 @@
%%==============================================================================
%% Misc.
\usepackage{comment}
\usepackage{needspace}
% \usepackage{calc}
% \usepackage{fp}
% \usepackage{lipsum}
@ -84,7 +105,7 @@
% \usepackage{listings}
%% Source code.
% \lstdefinestyle{customc}{
% \lstdefinestyle{custom}{
% % numbers=left,
% belowcaptionskip=1\baselineskip,
% breaklines=true,
@ -101,7 +122,7 @@
% numberstyle=\ttfamily
% }
% \lstset{escapechar=@,style=customc}
% \lstset{escapechar=,style=custom}
%%=============================================================================
%% Babel
@ -126,9 +147,9 @@
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\maketitle
\vfill
\thispagestyle{empty}
\tableofcontents
% \vfill
% \thispagestyle{empty}
% \tableofcontents
$0

View File

@ -1,6 +1,6 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key: table
# key: tab
# group: environments
# name : \begin{table} ... \end{table}
# --

View File

@ -0,0 +1,13 @@
# -*- mode: snippet -*-
# contributor : Pierre Neidhardt <ambrevar@gmail.com>
# key: tbl
# group: environments
# name : BEGIN RECEIVE ORGTBL
# --
% BEGIN RECEIVE ORGTBL ${1:table_name}
% END RECEIVE ORGTBL $1
\begin{comment}
#+ORGTBL: SEND $1 orgtbl-to-latex
| $0 |
%$
\end{comment}