latexer

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

latexer

Unread post by machinebacon » Thu Jun 26, 2014 6:45 pm

Creates a LaTeX template for articles, with different sections.

Code: Select all

#!/bin/bash

# for document classes, see http://texcatalogue.ctan.org/bytopic.html#classes

# set defaults
DOCCLASS_DEF=article
FONTSIZE_DEF=10
AUTHORNAME_DEF=(`whoami`)
TITLE_DEF=none
DOCDATE_DEF=today

# ask for user input
read -p "Font size in pt (default: $FONTSIZE_DEF) > " FONTSIZE
read -p "Document class (default: $DOCCLASS_DEF) > " DOCCLASS
read -p "Author's name (default: $AUTHORNAME_DEF) > " AUTHORNAME
read -p "Title (default: $TITLE_DEF) > " TITLE

# check if defaults are changed
FONTSIZE="${FONTSIZE:-$FONTSIZE_DEF}"
DOCCLASS="${DOCCLASS:-$DOCCLASS_DEF}"
AUTHORNAME="${AUTHORNAME:-$AUTHORNAME_DEF}"
TITLE="${TITLE:-$TITLE_DEF}"

# Summary
echo Creating $DOCCLASS template named $TITLE with font size of $FONTSIZE pt written by $AUTHORNAME.

# add pt without space
PT="pt"
FONTSIZEPT=`echo $FONTSIZE$PT`
read -p "Save template in /home/$USER as > " TEMPLATE

# create heredoc
cat > /home/$USER/$TEMPLATE <<EOF

\title{$TITLE}
\author{$AUTHORNAME}
\date{\today}

\documentclass[$FONTSIZEPT]{$DOCCLASS}

\begin{document}
\maketitle

\begin{abstract}
Abstract here...
\end{abstract}

\section{Introduction}
This is the introduction

\paragraph{Outline}
This is the outline
\bibliographystyle{abbrv}
\bibliography{main}

\end{document}
EOF

# start Emacs - switch to whizzytex for live preview
emacs -nw /home/$USER/$TEMPLATE
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: latexer

Unread post by GekkoP » Thu Jun 26, 2014 7:06 pm

Nice, very nice. Time put some LaTeX on Emacs now. ;)

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: latexer

Unread post by machinebacon » Thu Jun 26, 2014 7:08 pm

Just get whizzytex, that should be enough :)

(lol, I just wanted to press C-x C-c to send the message...)
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: latexer

Unread post by GekkoP » Thu Jun 26, 2014 7:13 pm

^ oh cool, thanks for the tip. And yeah, those wacky escape sequences...

User avatar
wei2912
runs Stable
Posts: 36
Joined: Wed Jun 18, 2014 7:59 pm
Location: Singapore

Re: latexer

Unread post by wei2912 » Thu Jun 26, 2014 8:04 pm

This is incredibly useful :D
GitHub || Blog

"Don't blindly believe what I say. Don't believe me because others convince you of my words. Don't believe anything you see, read, or hear from others, whether of authority, religious teachers or texts." - Buddha

Post Reply