Login

Welcome, Guest. Please login or register.

March 30, 2024, 01:24:46 am

Author Topic: Graphics in Latex  (Read 7107 times)  Share 

0 Members and 1 Guest are viewing this topic.

Mao

  • CH41RMN
  • Honorary Moderator
  • Great Wonder of ATAR Notes
  • *******
  • Posts: 9181
  • Respect: +390
  • School: Kambrya College
  • School Grad Year: 2008
Re: Graphics in Latex
« Reply #15 on: May 24, 2010, 04:10:19 am »
0
Oh, and regarding /0's graphics problem (it'll probably be solved a long time ago), these unix things don't really like the windows backslash for addresses. Forward slash for paths. Or, save the .tex file in some folder, and put the image in the same directory.
Editor for ATARNotes Chemistry study guides.

VCE 2008 | Monash BSc (Chem., Appl. Math.) 2009-2011 | UoM BScHon (Chem.) 2012 | UoM PhD (Chem.) 2013-2015

Cthulhu

  • Guest
Re: Graphics in Latex
« Reply #16 on: May 24, 2010, 05:24:45 pm »
0
Resurrecting this, but for anyone who's interested, here's the template file I use. Built this myself over the years, kinda does everything a professional document needs to do.

Code: [Select]
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage{multicol}
\usepackage{verbatim}
\usepackage{url}
\usepackage[top=2.5cm,bottom=2.5cm,left=2cm,right=2cm]{geometry}

\usepackage{listings}
\lstset{basicstyle=\footnotesize, language=Matlab, numbers=left, stepnumber=1, numbersep=5pt}

\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\lhead{MTH3051 - Introduction to Computational Mathematics}
\chead{}
\rhead{Assignment 1}
\lfoot{Mao Yuan Liu - 21513856}
\cfoot{}
\rfoot{Page \thepage}

\title{MTH3051 Assignment 1}
\author{Mao Yuan Liu}

\begin{comment}
Sample Code for inserting graphics
\begin{figure}[h]
\centering
\caption{CAPTION}
\includegraphics[width=0.5\textwidth]{C:/Users/picture.png}
\end{figure}

Sample Code for multicol
\begin{multicols}{2}
\end{multicols}

Sample footnotes
\footnote{text}

Sample Code snippet
\begin{lstlisting}
CODE HERE
\end{lstlisting}
\end{comment}

\begin{document}

\maketitle


\end{document}
Thanks Mao. I'll keep this archived for next semester.

/0

  • Victorian
  • ATAR Notes Legend
  • *******
  • Posts: 4124
  • Respect: +45
Re: Graphics in Latex
« Reply #17 on: May 24, 2010, 11:51:19 pm »
0
Thanks a bunch Mao, that's awesome :)

TrueTears

  • TT
  • Honorary Moderator
  • Great Wonder of ATAR Notes
  • *******
  • Posts: 16363
  • Respect: +667
Re: Graphics in Latex
« Reply #18 on: May 24, 2010, 11:53:45 pm »
0
ahh ive been using this layout ever since he posted it up sometime last year good stuff ey
PhD @ MIT (Economics).

Interested in asset pricing, econometrics, and social choice theory.

Cthulhu

  • Guest
Re: Graphics in Latex
« Reply #19 on: May 25, 2010, 12:14:27 am »
0
Also:
Code: [Select]
\usepackage[version=3]{mhchem}
Is a brilliant package if you need to input chemical formulas.
Documentation

TrueTears

  • TT
  • Honorary Moderator
  • Great Wonder of ATAR Notes
  • *******
  • Posts: 16363
  • Respect: +667
Re: Graphics in Latex
« Reply #20 on: May 25, 2010, 12:15:21 am »
0
Also:
Code: [Select]
\usepackage[version=3]{mhchem}
Is a brilliant package if you need to input chemical formulas.
Documentation
now thats hot
PhD @ MIT (Economics).

Interested in asset pricing, econometrics, and social choice theory.

zzdfa

  • Victorian
  • Forum Obsessive
  • ***
  • Posts: 328
  • Respect: +4
Re: Graphics in Latex
« Reply #21 on: June 08, 2010, 10:24:52 pm »
0
here's my compact problem set template with some useful maths shortcuts,
Code: [Select]
\documentclass[a4paper, 10pt]{article}
\usepackage[latin1]{inputenc}    % Accept european-encoded (latin1) characters.
\usepackage[a4paper,left=2.5cm,right=2.5cm,bottom=2.5cm,includefoot]{geometry}
\usepackage[parfill]{parskip} % skip a line instead of indenting new paragraphs
\usepackage{graphicx}   % For eps figures
\usepackage{epsfig}     % Alternative package
 
\usepackage{fancyhdr}
\fancyhead[L]{\class \,\, \assignment }
\fancyhead[R]{\author}
\renewcommand{\footrulewidth}{0.5pt} % Insert a line above the footer
\pagestyle{fancy}
\usepackage[hang,small,bf]{caption}
\usepackage{palatino}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{graphicx}
% convenience commands
\renewcommand{\author}{Peter Lin \quad 22041605}
\newcommand{\class}{MTH3140 Real Analysis}
\newcommand{\instructor}{}
\newcommand{\assignment}{Assignment 4}
\newcommand{\norm}[1]{\left|\!\left| #1 \right|\!\right|}
\newcounter{prob_num}
\setcounter{prob_num}{1}
\newcounter{subprob_num}
% usage: \problem
\newcommand{\problem}{\par\textbf{Q\arabic{prob_num}}.\stepcounter{prob_num}\setcounter{subprob_num}{1}\par}
\newcommand{\subprob}{\par\textbf{\alph{subprob_num}.\quad}\stepcounter{subprob_num}}
% usage: \head{name}{class}{assignment}
% usage: \eqn{equation}{label}
\newcommand{\eqn}[2]{\begin{equation}#1\label{#2}\end{equation}}
 
 
 
 
 \newtheorem{lemma}[equation]{Lemma}
 \newtheorem{corollary}[equation]{Corollary}
 \newtheorem{proposition}[equation]{Proposition}

 
 
 
 
 %%%%%%%%%%%%%%%% Anton's Shortcuts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\proclaim #1. #2\par{\medbreak \noindent \textbf{#1.} \textit{#2}\par\medbreak}
 \newcommand{\anton}[1]{[[\index{"!@notes and corrections}
                        \ensuremath{\bigstar\bigstar\bigstar} #1]]}
 \newcommand{\bbar}[1]{\overline{#1}}
 \newcommand{\bigast}{\text{\Large $\ast$}}
 \newcommand\C{\mathcal{C}}
 \DeclareMathOperator{\coker}{coker}
 \newcommand{\CC}{\ensuremath{\mathbb{C}}}
 \newcommand{\D}{\ensuremath{\mathcal{D}}}
 \DeclareMathOperator{\End}{End}
 \DeclareMathOperator{\ext}{Ext}
 \newcommand{\F}{\ensuremath{\mathcal{F}}}
 \let\hom\relax % kills the old hom
 \DeclareMathOperator{\hom}{Hom}
 \renewcommand{\H}{\widetilde H}
 \renewcommand{\labelitemi}{--}                    % changes the default bullet in itemize
 \newcommand{\id}{\mathrm{Id}}
 \DeclareMathOperator{\im}{im}
 \newcommand{\inn}[1]{\accentset{\circ}{#1}}
 \newcommand{\po}{\rule{5pt}{.4pt}\rule{.4pt}{5.4pt}\llap{$\cdot$\hspace{1pt}}}
 \newcommand{\pb}{\rule{.4pt}{5.4pt}\rule[5pt]{5pt}{.4pt}\llap{$\cdot$\hspace{1pt}}}
 \newcommand{\PP}{\mathbb{P}}
 \newcommand{\QQ}{\ensuremath{\mathbb{Q}}}
 \newcommand{\RR}{\ensuremath{\mathbb{R}}}
 \newcommand{\smalltrix}[4]{\ensuremath{\left( %
            \begin{smallmatrix} #1 & #2 \\ #3 & #4 \end{smallmatrix} \right)}}
 \DeclareMathOperator{\tor}{Tor}
 \newcommand{\W}{\Omega}
 \newcommand{\ZZ}{\ensuremath{\mathbb{Z}}}
 
 
 
 
 
 
 
 
% begin document
\begin{document}

\end{document}



sample output: https://docs.google.com/fileview?id=0B5lhiYSSECAUYzE4YmY1M2QtOTIyOC00Njc4LTgzYjctMGQ3MmVmMDlhM2Ux&hl=en
\RR and \QQ give you blackboard R or Q, see header for more shortcuts.
type \problem to start a new problem, type \subprob for a subproblem

e.g.

Code: [Select]
\problem
\subprob
\subprob
\problem
\subprob
\subprob

gets you

Q1.
a.
b.
Q2.
a.
b.



zzdfa

  • Victorian
  • Forum Obsessive
  • ***
  • Posts: 328
  • Respect: +4
Re: Graphics in Latex
« Reply #22 on: June 08, 2010, 10:25:12 pm »
0
I also made a python script that converts excel tables (in csv format) to tex tables: http://img14.imageshack.us/img14/2752/textable1.png

Code: [Select]
import csv


def formatrow(row,math):
    #takes a list and formats it to latex
    o='\n'
    i=0   
    for cell in row:
        s=i in math           
        o=o+'\t'+s*'$' +cell+ s*'$'+'\t&'            #adds $ $ if column is designated as math
        i+=1
    return o[0:-1] #delete trailing ampersand.
       



##getting user input
filepath=str(raw_input('Path to input file? '))
math=eval(raw_input('Which columns should be math\'d? [Enter as tuple e.g. "(0,2,3)"] '))               # tuple containing indices of columns that should be in maths format





##get the table into nested list form,
##table[i][j] is the jth entry of the ith row, start at 0,0
csvfile=open(filepath,'r')

table=[]
for row in csv.reader(csvfile,dialect='excel'):
    table.append(row)
   
csvfile.close()
   

##get info about table size
numrows=len(table)
numcols=len(table[0])




##output


f=open(filepath+'.tex','w')
f.write('%% {0} \n%% {1} rows and {2} columns \n'.format(filepath,numrows,numcols))


##make header string
cs=''.join(['c ' for i in xrange(numcols)])

hs="\\begin{tabular}{"

hs=hs+cs+'}'


f.write(hs)
##headings
f.write('\n \\hline')
f.write(formatrow(table[0],()))

f.write('\n \\tabularnewline \n \\hline \n \\hline')


##write table

i=1
for row in table[1:]:        #after header
    f.write(formatrow(row,math))
    if i<numrows:         #dont print at the end
        f.write('\t \\tabularnewline')



f.write('\n \\end{tabular}')

f.close()

raw_input('Output to {0}. Press ENTER to exit.\n'.format(filepath+'.tex'))

##todo : header column settings , assume pm = multicol

##do input/output pics
##do i/o stuff