惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

Comments for all models are wrong

-> Going both ways in R <- Simple animation and saving movies in Python Simple animation and saving movies in Python
Latex, Beamer, Python, Beauty
mikedewar · 2009-02-26 · via Comments for all models are wrong

This post quickly shows how to create pretty latex beamer slides, that don’t look anything much like maths seminar slides, and  that can include well formatted (Python) code, as well as the normal stuff that Beamer is so good at (maths, videos, etc). I’m assuming you’ve got a `standard’ install of latex (by standard I mean: like mine) that includes beamer and the listings package. I’m also assuming that you already know how to use beamer, so I’ve not included all the documentclass junk and so on. Here’s a taster of what it looks like, how to do it is after the break:

beamer_screen

There are three things we need to do to make beamer slides like this that don’t look like those endless maths-y beamer slides that everyone seems to like for some reason.

  1. Get rid of all the junk on the top and the bottom! No-one can see it anyway!
  2. Make the colours of the presentation very pretty.
  3. Make the listings use a better font than courier, and also use pretty colours!

1: get rid of all the junk

This is an awesome command. It’s (maybe) the longest single command ever in the world, sort of like that village in Wales with the huge name:

/usetheme{default}
/beamertemplatenavigationsymbolsempty

So now, your beamer presentation is nice and clean and happy.

2: Make Pretty Colours

This is just like knowing the magic words. We define a colour, then we assign it to a magic word. So lets define three colours, a background, a foreground and a title colour:

/definecolor{fore}{RGB}{249,242,215}
/definecolor{back}{RGB}{51,51,51}
/definecolor{title}{RGB}{255,0,90}

These colours are awesome but obviously you can choose your own if you’re a philistine and disagree. I’ve chosen the names (like fore), but they can be whatever you like. You can use other colour specifications instead of RGB, though using RGB for a presentation makes sense to me because it’s probably never going to be read seriously on paper. Now we need to tell beamer to actually use them:

/setbeamercolor{titlelike}{fg=title}
/setbeamercolor{normal text}{fg=fore,bg=back}

there are millions of these magic words like ‘titlelike’ but no-one will tell you what they are.

3: Make the listings pretty!

To include code listing (like Python) we use the listings package because it’s brilliant. We need:

/usepackage{listings,bera}
/definecolor{keywords}{RGB}{255,0,90}
/definecolor{comments}{RGB}{60,179,113}
/lstset{language=Python,
keywordstyle=color{keywords},
commentstyle=color{comments}emph}

The packages are for the listsings (clearly) and bera is the font. It’s secretly Bitstream Vera but they had to change the name or something because the world is messed up! Anyway bera is a lovely font in my honest opinion and you should use this and not courier which is ugly and very last century.

The colours are for comments and keywords which you’ll see in a sec, be patient.

The funny lstset command tells the listings package some things. The first is that we’re using Python. There are other languages, I think, but why we wouldn’t be using Python is beyond me. Then we ask listings to make our keywords the colour we defined above (pink!) and our comments to be the comment colour and also emphasised!

Finally, we must make a sample page to demonstrate the lstlisting environment, and because there’s one more important thing that is NOT OBVIOUS! Here’s a sample page:

/begin{frame}[fragile]
/frametitle{A Page}
/begin{lstlisting}
def list_of_vectors(n,T):
 return [matlib.zeros((n,1)) for t in T]
/end{lstlisting}
 Here is an equation:
 /begin{equation}
 x_t = Ax_{t-1} + w_t
 /end{equation}
/end{frame}

The thing to note is the [fragile] command. Here’s what it does. It means that the weird error that happens if you don’t include it DOESN’T HAPPEN! Enjoy!