Some not-oft used snippets for LaTeX.
We want to create a command containing the character count of a string.
%% Character-counting code from [1] %% [1] http://tex-and-stuff.blogspot.com.au/2011/03/counting-number-of-characters-in-tex_10.html \def\gobblechar{\let\char= } \newcount\charcount \def\countunlessnil{% \ifx\char\nil \let\next=\relax% \else% \let\next=\auxcountchar% \advance\charcount by 1% \fi\next }% \def\auxcountchar{% \afterassignment\countunlessnil\gobblechar% } \def\countchar#1{\edef\xx{#1}\charcount=0 \expandafter\auxcountchar\xx\nil} \def\shownumchar#1{% \countchar{#1}% There are \the\charcount\ characters in [#1].% } %% Do the counting of characters in #1 and store in \#2 %% XXX: I'm not sure this actually works \newcommand{\countcharout}[2]{% \countchar{#1}% \expandafter\def\csname #2\endcsname{\the\charcount}% } \countcharout{\theAuthor}{theAuthorLength} \countcharout{\theTitle}{theTitleLength} \show\theAuthorLength
\lstdefinestyle{C}{language=C, extendedchars=true, tabsize=4, showstringspaces=false, numbers=right, stepnumber=1, numberstyle=\tiny, numberblanklines=false breaklines=true, breakindent=5pt, postbreak=\empty}
\lstdefinestyle{LaTeX}{language=[LaTeX]tex, morekeywords={maketitle, tableofcontents, vref, pageref, addbibresource, printbibliography, hypersetup, text, gather, align, eqref, verbatim, verbatiminput, verb, usetheme, frametitle, framesubtitle, algorithms, algorithm, algorithmic, WHILE, ENDWHILE, multirow, toprule, midrule, cmidrule, bottomrule, subsection, subsubsection, chapter, part, paragraph, appendix, figurename, tablename, lstlistingname, includegraphics, graphicspath, resizebox}, emph={}, % Avoid inheriting BibTeX's emphs, for some reasson... %basicstyle=\scriptsize, breakatwhitespace, breaklines, basicstyle=, breakatwhitespace, breaklines, escapeinside={\%@}{@}, %showtabs,tabsize=4,tab=\rightarrowfill, prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}}, label=,caption=, frame=single, captionpos=b, %numbers=left,xleftmargin=2em, numbers=none}
\lstdefinelanguage{BibTeX}{keywords={% @article,@book,@collectedbook,@conference,@electronic,@ieeetranbstctl,% @inbook,@incollectedbook,@incollection,@injournal,@inproceedings,% @manual,@mastersthesis,@misc,@patent,@periodical,@phdthesis,@preamble,% @proceedings,@standard,@string,@techreport,@unpublished% }, emph={abstract, address, annote, author, booktitle, chapter, crossref, edition, editor, eprint, howpublished, institution, journal, key, month, note, number, organization, pages, publisher, school, series, title, type, url, volume, year,% }, emphstyle=\sf, comment=[l][\itshape]{@comment}, sensitive=false, }
\lstdefinestyle{Matlab}{language=Matlab,
extendedchars=true, tabsize=4,
showstringspaces=false,
numbers=left,
breaklines=true, breakindent=5pt, postbreak=\empty}
The same with colours:
\usepackage{color}
\lstdefinestyle{MatlabCol}{style=Matlab,
keywordstyle=\color{blue}\bfseries,
commentstyle=\color{red}
}
(a subset thereof)
\lstdefinelanguage{b}{
morekeywords={MACHINE, SETS, CONSTANTS, PROPERTIES, VARIABLES, INVARIANT, INITIALISATION, OPERATIONS, IMPLEMENTATION, REFINES, ANY, WHERE, THEN, END, VALUES, CONCRETE_VARIABLES},
morecomment=[l]{//},
morecomment=[s]{/*}{*/}
}
\lstset{language=b, tabsize=4, basicstyle=\small\ttfamily, breaklines=true, keywordstyle=\bf}
\usepackage {graphicx}
\unitlength 1cm
\begin{picture}(0,0)
\put(1.5,-23.2){
\begin{rotate}{20}
\includegraphics{confidentiel.png}
\end{rotate}
}
\end{picture}
Another option, text-only:
\usepackage {graphicx}
\usepackage{color}
\unitlength 1cm
\begin{picture}(0,0)
\put(1.5,-23.2){\rotatebox{20}
{\scalebox{9}{{\definecolor{Gris}{gray}{0.8}
\textcolor{Gris}{Confidential}}}}}
\end{picture}
\usepackage{graphicx}
\usepackage{fancyhdr}
\chead{
\begin{picture}(0,0)
\put(-7.5,-11.5){\includegraphics{SuperMouette_filigrane_nb.png}}
\end{picture}
}
\usepackage{vmargin}
\setmarginsrb{GAUCHE}{HAUT}{DROITE}{BAS}{GAUCHE-TEXTE}{HAUT-TEXTE}{DROITE-TEXTE}{BAS-TEXTE}
$ fig2dev -L pdftex -B "0 0 0 0" SOURCE.fig DEST.pdftex $ fig2dev -L pdftex_t -p DEST.pdftex SOURCE.fig DEST.pdftex_t
for file in *.fig; do cat $file | sed \ -e "s/^4 [[:digit:]]\+ \([[:digit:]]\+ [[:digit:]]\+ -\?[[:digit:]]\+\) [[:digit:]]\+ \([[:digit:]]\+ [[:digit:]]\+\.[[:digit:]]\+\) [[:digit:]]\+ \([^\$]*\)/4 0 \1 1 \2 0 \3/" \ -e "s/^4 [[:digit:]]\+ \([[:digit:]]\+ [[:digit:]]\+ -\?[[:digit:]]\+ [[:digit:]]\+ [[:digit:]]\+ [[:digit:]]\+\.[[:digit:]]\+\) [[:digit:]]\+ \(.*\$.*\)/4 1 \1 2 \2/" \ > ${file}2 mv ${file}2 $file done
%% Preamble
\usepackage{graphicx}
\DeclareGraphicsRule{*}{pdf}{*}{}
%% [...]
%% Document
\resizebox{\textwidth}{!}{\input{FILE.pdftex_t}}
\documentclass{article} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage{color} \usepackage{calc} \makeatletter \renewcommand{\section}{\@startsection {section}{1}{\z@}% {-3.5ex \@plus -1ex \@minus -.2ex}% {2.3ex \@plus.2ex}% {\@colorboxsection}} \newcommand{\@colorboxsection}[1]{% \noindent\colorbox{black}{\Large\bfseries\makebox[\textwidth-1ex][l]{\textcolor{white}{#1}}}% } \begin{document} \section{section} \end{document}
The following can be done to change the way a counter is rendered; either using the rendering of more than one counter, or adding additional static elements.
\renewcommand{\theCOUNTER}{S.\theOTHERCOUNTER.\arabic{COUNTER}}
Let BibTeX take care of the proper capitalisation of titles.
Replace the opening brace on each line:
:%s/^\([^=]*title \+=[^{]*\){/\1"
and the last one:
:%s/^\([^=]*title \+=.*\)}\(,\?\)$/\1"\2/
Using ps2pdf14 is often suggested around the web.
$ pdftops SRC - | ps2pdf14 -dPDFSETTINGS=/prepress - DST
However, converting to PostScript loses various things such as bookmarks and PDF links. Using gs directly seems to work better.
$ gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dEmbedAllFonts=true -sOutputFile=DST SRC
\def\Tiny{\fontsize{4pt}{4pt}\selectfont}
It's always good to plan ahead of Q&A, and have backup slides. However, with numbered slides (as they *always* should be), counting the backup slides in could very well scare the audience (“Wow, still 60 to go, and the presentation ends in 10 minutes!”).
A quick backup environment solves the problem nicely.
\renewcommand{\appendixname}{Backup} %% Based on [0] %% [0] http://stackoverflow.com/questions/732902/ignoring-page-numbers-in-backup-slides \newenvironment{backup}{ \only<beamer>{\setbeamertemplate{footline}[default]} \newcounter{framenumberbeforeappendix} \appendix \section*{\appendixname} \label{sec:backup} \frame{ \centering \Huge\nameref{sec:backup} } \setcounter{framenumberbeforeappendix}{\value{framenumber}} }{ \addtocounter{framenumberbeforeappendix}{-\value{framenumber}} \addtocounter{framenumberbeforeappendix}{-1} \only<beamer>{\addtocounter{framenumber}{\value{framenumberbeforeappendix}}} }
This is nicely complemented by sprinkling hypertext buttons to the relevant backup slides within the main body.
\newcommand{\button}[3]{% \only<beamer>{\hyperlink{#2}{\csname beamer#1button\endcsname{#3}}}% \only<handout>{{\footnotesize[#3 on slide \ref{#2}]}}% } \newcommand{\gotobutton}[2]{\button{goto}{#1}{#2}} \newcommand{\returnbutton}[2]{\button{return}{#1}{#2}}
This way, a simple \gotobutton{see there}{frame:backup-here} would create a button saying “see there” pointing to the slide with \label{frame:backup-here}.
Note the conditional change in footline in the backup environment, and that in the definition of \button. This allows to generate nice handouts with the same code, where the button is replaced by a textual framenumber reference, and the frames are actually numbered within the backup too.
%\renewcommand{\textfraction}{0.07} \renewcommand{\topfraction}{1} \renewcommand{\bottomfraction}{1} \renewcommand{\floatpagefraction}{1} \renewcommand{\dblfloatpagefraction}{2}