- PDF: tpavlic_nsf_biosketch.pdf
- LaTeX template: tpavlic_nsf_biosketch.tex
Personal weblog of Ted Pavlic. Includes lots of MATLAB and LaTeX (computer typesetting) tips along with commentary on all things engineering and some things not. An endless effort to keep it on the simplex.
Showing posts with label latex. Show all posts
Showing posts with label latex. Show all posts
Monday, February 04, 2013
LaTeX template for NSF-style Biographical Sketch
On large multi-university NSF grant proposals, NSF requires that senior personnel submit a 2-page biographical sketch ("biosketch") that is formatting according to certain rules in their Grant Proposal Guide (GPG). The format is pretty simple, and so there does not seem to be much demand for a solid LaTeX template for one. Nevertheless, I thought some people might find one helpful.
I've posted a PDF of my NSF-style biosketch below along with the TeX source used to generate it.
Tuesday, October 09, 2012
natbib-like frontend for chicago-style macros
For some reason, the ACM has baked in chicago-like citation macros into the ACM SIG proceedings LaTeX templates instead of using the far superior natbib that literally everyone else on the planet uses.
I'm much more accustomed to typing \citet as opposed to \shortciteN, \citeauthor as opposed to \shortciteANP, etc. So I decided to add this little translation table to my preamble:
It's crazy how chicago-style macros sometimes use "N" to mean "noun" and other times to be the first half of "NP" being "no parentheses."
Unfortunately, that means I can't use any of the optional arguments to \citep or \citet. If you are just looking for a translation table so you can use the chicago-style macros directly, try this:\def\citet{\shortciteN} \def\Citet{\shortciteN} \def\citeauthor{\shortciteANP} \def\Citeauthor{\shortciteANP} \let\chicagociteyear\citeyear \def\citeyearpar{\chicagociteyear} \def\citeyear{\citeyearNP} \def\citep{\shortcite}
natbib | chicago |
---|---|
\citet or \Citet | \shortciteN |
\citeauthor or \Citeauthor | \shortciteANP |
\citeyear | \citeyearNP |
\citeyearpar | \citeyear |
\citep | \shortcite |
Thursday, August 09, 2012
CTAN search engine definition for Firefox
If you're looking for search engine definitions for CTAN that are compatible with Firefox's search toolbar, then visit:While on that page, click on the down arrow in the icon in your your Firefox search toolbar. You should see several "Add" options at the bottom. That lets you add several different types of CTAN search to your toolbar.
You can then "Manage Search Engines" and add a keyword to some of them. I use the keyword "ctan" to search package ID's and the keyword "ctanp" to search over package ID's and descriptions. The keyword lets me search directly from the awesome bar without having to use the search bar.
[ These definitions were inspired by firefox_ctan_plugins by Martin Engler, but those don't work with CTAN anymore. ]
Thursday, August 25, 2011
Using \gobblepars to prevent LaTeX from adding empty lines at gaps
While searching for something else, I came upon a StackOverflow question from a while ago that asked how to prevent LaTeX from adding a \par at particular blank lines in the source code. The asker didn't want to remove blank spaces everywhere; he just wanted to get rid of the paragraphs at certain spots.
Of course, you can use comments to do this:
Here's the simple definition of \globblepars (you put this in the preamble of your LaTeX document):
Of course, you can use comments to do this:
However, a lot of people don't like the look of that. Some of the responders on StackOverflow gave some alternatives that seemed ugly and half baked. So I came up with \gobblepars, which is a macro you can add to the end of your own macro definitions to cause them to eat up all trailing pars, or you can use explicitly. For example:\somemacro{} % Some text
would do the same as the commented stuff above. Moreover, if you had control over \somemacro, you could build \gobblepars into it (in fact, even if you didn't have control, you could use \let and \def to augment an existing macro with a trailing \gobblepars, but that's a different topic).\somemacro{}\gobblepars Some text
Here's the simple definition of \globblepars (you put this in the preamble of your LaTeX document):
So that's pretty simple. It checks for a \par (which includes a blank line in the source) trailing it. If it finds one, it gobbles it up (i.e., gets rid of it) and then calls itself again. This process will continue until it finds something other than a \par. Hence, it "gobbles" strings of "pars".\makeatletter \newcommand\gobblepars{% \@ifnextchar\par% {\expandafter\gobblepars\@gobble}% {}} \makeatother
Labels:
cross-references,
gobblepars,
hacks,
howto,
latex,
latex examples,
tex,
TeX/LaTeX
Tuesday, August 23, 2011
Update to my LaTeX CV templates: Space allowed after sections now!
In preparation for setting up MultiMarkDown (MMD) to write my CV for me, I've been thinking about ways to refactor my old résumé/CV LaTeX templates to make them look a little cleaner. A fix I came up with tonight should help with that, and I think it will also make the templates easier for others to work with even if they're not doing anything with MMD.
In particular, the \section macro used to be renewed as a \marginpar with some other ugly stuff. Putting the sections in the margins caused problems because people like to put spaces after the sections, which generates a \par that means the section content will not be aligned with the section heading in the margin note. So the old way I got around that problem was to force people not to use spaces between \section and the section content. If they needed visual space in their source code, they could use comments to do that.
Well, I've swapped out that ugly definition for a slightly less ugly one that uses \llap (with a \smashed \parbox) and some creative gobbling. In particular,
You can get my most recent LaTeX CV templates at their page on my website. You can find a detailed history of the source code changes within my Mercurial repositories of documents.
(updated: new \gobblepars allows for arbitrary amount of space after each \section)
(updated: replaced \gobblepars with \par hack that still allows for arbitrary amount of space after each \section but also prevents lists from adding a \par when placed directly after a \section; consequently, adjusted all of the lone-lists to get rid of their leading negative vertical space (probably can get rid of them now, actually). I'm trying to shift toward using conventional lists (or perhaps conventional modifications of them from paralist or enumitem))
In particular, the \section macro used to be renewed as a \marginpar with some other ugly stuff. Putting the sections in the margins caused problems because people like to put spaces after the sections, which generates a \par that means the section content will not be aligned with the section heading in the margin note. So the old way I got around that problem was to force people not to use spaces between \section and the section content. If they needed visual space in their source code, they could use comments to do that.
Well, I've swapped out that ugly definition for a slightly less ugly one that uses \llap (with a \smashed \parbox) and some creative gobbling. In particular,
The \vspace and \par combination should ensure that an additional \par isn't added by LaTeX. So before you were restricted to things like...% The section headings % % Usage: \section{section name} \renewcommand{\section}[1]{\pagebreak[3]% \hyphenpenalty=10000% \vspace{1.3\baselineskip}% \phantomsection\addcontentsline{toc}{section}{#1}% \noindent\llap{\scshape\smash{% \parbox[t]{\marginparwidth}{\raggedright #1}}}% \vspace{-\baselineskip}\par}
and\section{Stuff} \begin{bibsection} %...
But now you don't have to be so careful about the whitespace. You are allowed:\section{Stuff} % Junk
and\section{Stuff} \begin{bibsection} %...
So that's cool. Much more readable.\section{Stuff} Junk
You can get my most recent LaTeX CV templates at their page on my website. You can find a detailed history of the source code changes within my Mercurial repositories of documents.
(updated: replaced \gobblepars with \par hack that still allows for arbitrary amount of space after each \section but also prevents lists from adding a \par when placed directly after a \section; consequently, adjusted all of the lone-lists to get rid of their leading negative vertical space (probably can get rid of them now, actually). I'm trying to shift toward using conventional lists (or perhaps conventional modifications of them from paralist or enumitem))
Labels:
curriculum vitae,
cv,
latex,
latex examples,
latex templates,
resume,
tex,
TeX/LaTeX,
texlatex
Monday, June 13, 2011
Someone asked me for some references on LaTeX today...
I got an e-mail today asking for some recommended references on LaTeX. Here is my response, which is a marked-up paste of an e-mail.
[ This post can also be found on my web page. ]
[ This post can also be found on my web page. ]
The reference that I keep handy is:
The LaTeX Companion, Second Edition by Mittelbach and Goosens
That reference, often called TLC2, is a standard one. You really can't
go wrong with it. It's dense, includes lots of examples, and is pretty
easy to use. One other book that came in handy when I started drawing
graphics in LaTeX is:
The LaTeX Graphics Companionby Goosens, Rahtz, and Mittelbach
That introduced me to things like picture environments and PSTricks. I
use PSTricks a lot now, and the book really is only meant to be an
introduction (albeit a nice one) to PSTricks as well as other competing
(and complementary) tools. Now I typically use the PSTricks
documentation on the PSTricks home page at TUG (you can google for
"PStricks" to find the web page).
A nice small reference to LaTeX is:
LaTeX: A Document Preparation Systemby Lamport
A very complete but also intimidating reference for TeX is:
The TeXbookby Knuth
Three other notable and popular books on TeX (that are far less
intimidating) are:
You can still get that last book in print from some sources that print
- TeX for the Impatient
by Abrahams, Berry, and Hargreaves
- A Beginner's Book of TeX
by Seroul and Levy
- TeX by Topic: A TeXnician's Reference
by Eijkhout
out of print books (lulu.com), but I believe it has been released for free as a PDF as well. Yes, see:
for the free download link (released under GNU FDL).
[ If you really don't want to get into the nitty gritty details, I would
recommend sticking to the LaTeX references. ]
Otherwise, I've just done a lot of learning by doing. It helped to
learn about typesetting in general. A good reference for both things is
the documentation that comes with the memoir package:
That documentation link (memman.pdf) is an excellent introduction to all
- Package: http://ctan.org/pkg/memoir
- Documentation: http://mirror.ctan.org/macros/latex/contrib/memoir/memman.pdf
of the basic typographical elements of a book... and memoir is a nice
LaTeX package in general.
After that, see comp.text.tex (available as a Google group) which is
known simply as "CTT" to insiders...
LaTeX and TeX experts watch that group and will answer your questions
about how to do things. You can also search the group for some previous
answers to similar questions. You can also see announcements of new
versions of packages that do cool things. It's a great resource.
Finally, seeing the LaTeX 2e source (implemented in TeX) can be helpful
to understand exactly what goes on when you do things like a \section.
"source2e.pdf" is included with the LaTeX distribution. You can also
view it on-line here:
That includes all of the TeX implementations for the LaTeX macros and
gives you some idea of what goes on when you build a LaTeX document.
Off the top of my head, that's all I can think of. Just go into things
thinking that LaTeX probably *CAN* do whatever you want it to (including
solving and plotting differential equations, which pure LaTeX (as
opposed to PDFLaTeX) can do). Like a sculptor, you just have to figure
out what to chip away to get it to do it. Keep trying things until
something is qualitatively similar to what you want, and then tune
(perhaps with the help of CTT) after that. Eventually you'll come up
with better and better implementations. If you come up with something
especially novel, post it on-line. In fact, contributing to CTAN
directly is usually recommended.
Another thing that helps me is to remember that TeX is really is just a
giant machine that tokenizes, parses, and expands. It's not a
"programming language" so much as it is a text "filter" in that a single
run of LaTeX doesn't necessarily result in what you want. Keeping this
in the back of my head helps me anticipate the problems I might have
with certain approaches, and it further helps me figure out how to
approach LaTeX in order to succeed.
Wednesday, February 16, 2011
natbib-compatible BibTeX style (BST) file for Springer LNCS publications
UPDATE: Additionally, if you prefer "References" instead of "Bibliography", you have to re-define the \bibname macro in your document (e.g., just after you include natbib). Just add aFor some reason, the folks over at Springer do not like to make their BibTeX style (BST) files natbib compatible. This omission seems egregious when considering the kind of authors that would submit to journals and conferences that use LNCS-style formatting. Springer does provide LaTeX support files for LNCS, but the included BST file is not natbib compatible (because it was not built with natbib and author–year extensions turned on, which are needed in natbib even when numbered references are used). What makes things more difficult is that it is produced by hacking another BST (titto.bst) that was originally generated properly using makebst, and many of the hacks were already implemented natively in merlin.mbs. So much more of the postfix BST language was hacked directly rather than would have been necessary if the correct docstrip driver options were picked in the first place. So that makes it more challenging to reproduce a refactored version with additional natbib functionality without worrying about introducing regressions.or a\rewewcommand\bibname{\refname}and you should be up and running with your desired bibliography name.\renewcommand\bibname{References}
Nevertheless, I've done my best, and I've made the the natbib-compatible result splncsnat.bst available for download. I was able to remove the need for some of the manual editing by a smarter choice of docstrip options, but I still ended up having to create a patch on top of a stock docstrip-generated BST (the docstrip driver splncsnat-unpatched.dbj and patch splncsnat.patch are also available). Hopefully that helps someone out there.
- splncsnat.bst: natbib-compatible BST file for Springer LNCS-type publications
Download and place splncsnat.bst in same directory as document's TeX source code. In the TeX preamble of the document, use
and then in the text use macros like\usepackage[numbers]{natbib}
\bibliographystyle{splncsnat}
The normal \bibliography{FILENAME} can be used at the end of the text where the BBL will be inserted by BibTeX.\cite{smith77} % to get a "[1]" in the text
\citep{smith77} % to get a "[1]" in the text
\citet{smith77} % to get a "Smith [1]" in the text
\citeauthor{smith77} % to get a "Smith" in the text - splncsnat-unpatched.dbj: docstrip driver used to generate splncsnat-unpatched.bst
- splncsnat.patch: patch used to generate splncsnat.bst from splncsnat-unpatched.bst (assuming version 4.20 [2007/04/24 (PWD, AO, DPC)] of merlin.mbs)
Friday, February 11, 2011
Updated LaTeX document class for Ohio State University (OSU) graduate school dissertation and thesis documents
Back in 1996, The Ohio State University Electrical and Computer Engineering (ECE) department made available LaTeX2e support files including a document class that complied with the graduate school's format for dissertations (see samples pages, guidelines, templates, and other resources from the graduate school). The resulting osudissert96.cls and osudissert96-mods.sty from the ECE department was kept up to date through 1998, but it was left to lapse out of compliance after several format updates from the graduate school (including a recent one in 2009). Additionally, the graduate school only officially supports helping students with documents "typeset" in Microsoft Word (and even their Word templates may require a more recent version than they claim on the website).
So back when I put together my dissertation (which has source code available to review) in 2010, I updated those old ECE templates for the 2010 format. I tried to make them backward compatible with the old osudissert96 to make them nice drop-in replacements for anyone using the outdated versions. You can find them at:
I hope that helps someone out there. I probably won't be monitoring the graduate school format policies now that I am not in graduate school anymore, but I am usually happy to help with "how-to-modify" questions over e-mail (if I have time). Good luck!
So back when I put together my dissertation (which has source code available to review) in 2010, I updated those old ECE templates for the 2010 format. I tried to make them backward compatible with the old osudissert96 to make them nice drop-in replacements for anyone using the outdated versions. You can find them at:
- http://links.tedpavlic.com/zip/osudissert10.zip
- http://links.tedpavlic.com/zip/sample-osudissert10.zip
- Unzip sample-osudissert10.zip.
- Unzip osudissert10.zip.
- Put the CLS and STY files from osudissert10.zip into the same directory as the files from sample-osudissert10.zip
- Build the sample dissertation with:
- pdflatex Thesis.tex
- bibtex Thesis.aux
- pdflatex Thesis.tex
- pdflatex Thesis.tex
- Review the resulting Thesis.pdf file, which also includes documentation on how to get your own dissertation up and running.
I hope that helps someone out there. I probably won't be monitoring the graduate school format policies now that I am not in graduate school anymore, but I am usually happy to help with "how-to-modify" questions over e-mail (if I have time). Good luck!
Wednesday, September 08, 2010
How to put "1 of ..." page numbers on a LaTeX letter
Someone e-mailed me recently to ask how to add "1 of LAST_PAGE" page numbers to a LaTeX letter document. I generated the sample LaTeX document fancy_letter_numbering.tex to show how it's done using the fancyhdr and lastpage packages.
Here is my response, which gives more details:
[ Additionally, you may further customize the headings and footers making use of all of the nice features that come with the fancyhdr package. ]
Here is my response, which gives more details:
I have attached a sample letter with "1 of ..." page numbering throughout. fancyhdr works with "letter" just as well as it works with "article." You just have to treat "\opening" just like you do "\maketitle."Of course, you will have to run LaTeX (or PDFLaTeX) at least twice to place the "LastPage" label properly and generate the correct page refeference.
In particular, put this up in your preamble:\usepackage{lastpage}Then, after each "\opening" (in the case of a single letter, there will only be one), put the line:
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\cfoot{\thepage{}~of~\pageref{LastPage}}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}\thispagestyle{fancy}Otherwise you will get page numbers on every page except for the first one.
[ Additionally, you may further customize the headings and footers making use of all of the nice features that come with the fancyhdr package. ]
Labels:
hints,
howto,
latex,
latex examples,
latex templates,
letter,
letters,
tex,
TeX/LaTeX,
texlatex,
tips,
tricks,
typesetting,
writing
Saturday, March 21, 2009
rspublic.cls fixed to get rid of nasty Incomplete \if errors
Depending on how updated your LaTeX distribution is, if you try to use the Royal Society's rspublic.cls to build your compuscript, you may get nasty incomprehensible errors like:
After two days of binary searching through possible sources of the problem, I found it. Jonathan Wainwright (the author of the document class) used a \phantom in both the \@oddhead and \@evenhead without preceding it by a \protect. The \phantom macro is fragile, which means that it can cause major problems when put in contexts that move around (like headers). So it needs to be protected.
I added \protect in front of each of the two \phantom calls, and all was well in the world.
I've posted a fixed version of the document class at:Give it a shot. That version also allows for 11pt and 12pt fonts, and it defines \@ptsize, which setspace needs to exist in order to work (i.e., for double spacing).
I didn't get these errors on my home system (which has TeX Live 2007 installed), but I got them on Manuscript Central for Proc. R. Soc. B, and that's a major problem.! Incomplete \if; all text was ignored after line 7.
\fi
After two days of binary searching through possible sources of the problem, I found it. Jonathan Wainwright (the author of the document class) used a \phantom in both the \@oddhead and \@evenhead without preceding it by a \protect. The \phantom macro is fragile, which means that it can cause major problems when put in contexts that move around (like headers). So it needs to be protected.
I added \protect in front of each of the two \phantom calls, and all was well in the world.
I've posted a fixed version of the document class at:Give it a shot. That version also allows for 11pt and 12pt fonts, and it defines \@ptsize, which setspace needs to exist in order to work (i.e., for double spacing).
Labels:
bugs,
fixes,
fragile,
Jonathan Wainwright,
journals,
latex,
patches,
protect,
Royal Society,
rspublic,
tex,
TeX/LaTeX,
typesetting,
writing
Friday, March 20, 2009
natbib-compatible BST file for Royal Socety journals
I just whipped up rspublicnat.bst, which is a natbib-compatible BibTeX style file (BST) for the Royal Society journals (e.g., Proceedings of the Royal Society A and B and others).
FYI, the BST can be regenerated by applying LaTeX (i.e., docstrip) to rspublicnat.dbj and then applying rspublicnatbst.patch (with patch) to the resulting BST file. The patched result should closely match the Royal Society's bibliographic conventions for both in-line and listed references.
FYI, the BST can be regenerated by applying LaTeX (i.e., docstrip) to rspublicnat.dbj and then applying rspublicnatbst.patch (with patch) to the resulting BST file. The patched result should closely match the Royal Society's bibliographic conventions for both in-line and listed references.
Labels:
bibtex,
BiBTeX style files,
BST,
journals,
latex,
natbib,
Royal Society,
rspublic,
tex,
TeX/LaTeX,
typesetting,
writing
Thursday, March 19, 2009
Removing hyperref's space inside \autoref
Many journals (e.g., any of the Royal Society journals) prefer sections to be identified with the section symbol (§) rather than the word "section" followed by a space. If you use \auotref, one of the wonderful macros provided by the hyperref package, then you'll want to do something like...
\renewcommand*\sectionautorefname{\S}Unfortunately, \autoref will still insert a space between the section symbol (\S, which renders as §) and the section number. So, as discussed in a comp.text.tex posting, you'll need to be more clever and do something like (the ~ character is the "tilde", which is on the upper-left of most keyboards; it's a LaTeX "tie"—a non-breaking space)...
\def\Snospace~{\S{}}instead. That will eat the space that \autoref inserts after the section. Voila!
\renewcommand*\sectionautorefname{\Snospace}
Tuesday, March 17, 2009
Perl script that generates CSV and BerkeleyDB versions of LTWA list
UPDATE: If you're wondering why I just didn't save the LTWA database and search it every time I needed to abbreviate a journal, it's because I wanted to optimize for speed downstream. That is, I did all the possible processing now to speed things up later. I've also augmented the script to do the opposite (and save the results in other smaller files) so that I can tell the downstream process to take longer (and possibly have better results with less spurious entries in the hash table). I've also updated the downstream script to save any successful lookups locally to speed up successive runs. Again, contact me if you want more details.I'm sick of looking up ISO 4 standard journal abbreviations from the List of Title Word Abbreviations (LTWA) hosted at ISSN's LTWA online. The most annoying thing about LTWA online is that you can't get one big list unless you have them mail you a paper copy (for a price). So you have to resort to clicking each letter and waiting for the list for that letter to come up.
So I wrote a Perl script that automatically cURLs each LTWA online page down, processes it, and generates both CSV and BerkeleyDB (BDB) hash files containing a list of words and their associated official LTWA abbreviation. I use the BDB file in another script to automatically generate BibTeX database files for each of my journal papers (that script first checks a list of known-good journal abbreviations before trying to generate the abbreviation itself).
There were several challenges to such a task, and the list isn't perfect. I focused on one-word entries. For more complicated abbreviations, I figured I'd lean on my list of known-good journal abbreviations. That still left LTWA entries like "psycholog-" and "bulletin-" which use "-" to imply "and any other character." So I used a typical /usr/share/dict/words list to generate a list of English words that matched each pattern. Because such lists don't usually include plurals, I used Lingua::EN::Inflect to generate plurals and then took all of the plurals that included the singular (i.e., that would also match the LTWA pattern).
So that works well for me. Someday I might put the script and/or the files it produces on-line. For the moment, if you want any of these, contact me and let me know. I'll share.
Wednesday, March 11, 2009
"Interference" seems like an appropriate name
I got a request from a marketer that I link to his product from this blog:From him:
Perhaps I'm being a little too harsh. Interference's own website gives a better description of its features:
(by the way, my LaTeX build environment does the equivalent of "Interference for MATLAB" for LaTeX users. Among other things, if you \includegraphics{image_name} and the build environment finds an image_name.m file, it will automatically generate an image_name.eps (or image_name.pdf) whenever the MATLAB script gets updated)
Inference is a Microsoft Office add-in that has a point-and-click interface for adding MATLAB code, .m files, and structured data to Word and Excel documents. If you use Microsoft Office, Inference is an alternative to EX Builder and Notebook for generating reports, reproducible research, and Office applications. And regardless of whether you use Office, Inference has an integrated development environment (Inference Studio) with an intelligent editor that features breakpoints and edit-and-continue.I have no idea why you would possibly need such a thing. I view software like this as predatory—it preys on people who think they're helpless. They end up overlooking existing easy solutions (like using the debugging features of MATLAB's own editor) and get distracted from finding truly good solutions.
Perhaps I'm being a little too harsh. Interference's own website gives a better description of its features:
Inference for MATLAB allows you to:If you have use for such a thing... Give it a whirl, but don't come to me for help.
- Execute MATLAB code directly inside of Microsoft Word to create formatted reports that contain explanatory text and graphical/code output.
- Execute MATLAB code directly inside of Microsoft Excel to create dynamic spreadsheets that leverage existing Excel functionality.
- Store all of your MATLAB code, data, and M-Files inside a single Microsoft Word and Excel document.
(by the way, my LaTeX build environment does the equivalent of "Interference for MATLAB" for LaTeX users. Among other things, if you \includegraphics{image_name} and the build environment finds an image_name.m file, it will automatically generate an image_name.eps (or image_name.pdf) whenever the MATLAB script gets updated)
Labels:
Interference,
latex,
MATLAB,
Microsoft Excel,
Microsoft Office,
Microsoft Word,
publishing,
scripts
Thursday, December 25, 2008
BibTeX Bibliography Style File (BST) for Engineering Applications of Artificial Intelligence (EAAI)
The Elsevier journal Engineering Applications of Artificial Intelligence suggests that authors use the elsart-harv.bst BibTeX bibliography style (BST) file to match its Harvard-style author-year reference format. However, elsart-harv.bst does not match the conventions used in EAAI proofs. In particular,
[ NOTE: More-advanced users may prefer my elsart-harv-EAAI.patch. ]
- EAAI proofs use "Thesis" (instead of "thesis")
- EAAI proofs surround the volume of an "in proceedings" entry with commas (instead of periods)
- EAAI proofs use "vol." (instead of "Vol.")
- EAAI proofs don't put any space between abbreviated parts of author names (but they do keep the hyphens in hyphenated abbreviations)
\bibliographystyle{elsart-harv}line to
\bibliographystyle{elsart-harv-EAAI}Of course, elsart-harv-EAAI.bst is still natbib compatible.
[ NOTE: More-advanced users may prefer my elsart-harv-EAAI.patch. ]
Thursday, October 16, 2008
Fixing bug in hyperref's autoref: amsmath-type equations under items get "item" label
Earlier this year, in a comp.text.tex posting, I discussed a bug I found in hyperref. That bug was then fixed in hyperref 6.77a, but there are still plenty of old packages hanging around that have this bug (for example, the hyperref from TeXLive 2007 on my system that I still haven't upgraded to TeXLive 2008).
The problem happens when
To fix this problem, I use these lines of code just after I load hyperref in my preamble:
That fix changes all of the improper "item" labels back into proper "Equation" labels.
The problem happens when
- amsmath (or mathtools) is loaded.
- An equation (or any other type of displayed-math environment) environment with labels occurs INSIDE an enumerated item.
- You try to use \autoref to generate a reference to one of those equation labels later.
To fix this problem, I use these lines of code just after I load hyperref in my preamble:
The \AMShreffix (i.e., AMS-href-fix) macro "fixes" the displayed-math environment that you pass it. This example fixes equation, align, and gather. If you want to fix alignat too, add a \AMShreffix{alignat} at the end of those lines. Make similar changes for your other displayed-math environments (e.g., flalign and multline too).\makeatletter
\newcommand{\AMShreffix}[1]{%
\expandafter\let\csname old#1\expandafter\endcsname%
\csname #1\endcsname%
\expandafter\renewcommand\csname #1\endcsname{%
\@hyper@itemfalse\csname old#1\endcsname}}
\makeatother
\AMShreffix{equation}
\AMShreffix{align}
\AMShreffix{gather}
That fix changes all of the improper "item" labels back into proper "Equation" labels.
Tuesday, September 23, 2008
Fixing natbib: Adding tie between author and citation
Something that bugs me about natbib is that \citet puts a formal SPACE between the authors and the citation list, and so LaTeX like...
The best solution is to fix natbib so that this character is configurable. That would really help when using superscript references because you could get rid of the character all together (right now superscripts get a space before them, and that looks a little silly (especially when superscripts show up on the next line!)). However, that could take a while to get fixed (CTAN isn't quite SourceForge)... So I put together the following fix, which should work OK for \citet, \citet*, \Citet, and \Citet* regardless of how many optional arguments (0, 1, or 2) are present.
(note: the \makeatletter and \makeatother commands are not needed if these lines are put into a .sty file or in a natbib.cfg file (in the same directory as your TeX document source).
UPDATE: For author-year citations (i.e., "Harvard style citations"), you must replace the \citep with \citeyearpar. That is, replace the final section of the code above with this section:
that shows up near the end of a typeset line can turn into. . . as discussed by \citet{SK86}.
Not only does this put a number at the beginning of a line, which is a typography no-no when you aren't starting a numerical item in a list, but it separates the citation list from its neighbors. If natbib would just us a TIE (~ in TeX) instead, then the "Krebs" in the example above would never get separated from the "[1]."as discussed by Stephens and Krebs
[1].
The best solution is to fix natbib so that this character is configurable. That would really help when using superscript references because you could get rid of the character all together (right now superscripts get a space before them, and that looks a little silly (especially when superscripts show up on the next line!)). However, that could take a while to get fixed (CTAN isn't quite SourceForge)... So I put together the following fix, which should work OK for \citet, \citet*, \Citet, and \Citet* regardless of how many optional arguments (0, 1, or 2) are present.
(note: the \makeatletter and \makeatother commands are not needed if these lines are put into a .sty file or in a natbib.cfg file (in the same directory as your TeX document source).
Even if this problem gets fixed within natbib, it still might serve as a good example of how to deal with TWO or more optional arguments in macros...% Unfortunately, natbib does not TIE textual
% references to their citations. So authors
% sometimes get separated from citations when
% they come at the end of the line. The following
% lines attempt to fix this problem.
%
% The lines below do the equivalent of . . .
%
% \renewcommand\citet[1]%
% {\citeauthor{#1}~\citep{#1}}
%
% but they handle the star and capitalization and
% optional argument cases too.
%
% (the \makeatletter and \makeatother are not needed if
% these lines are put into a .sty file or in a natbib.cfg
% file)
\makeatletter
%
%%% These lines test for star and number of arguments
%%% and call the workhorses below
%
% Test for star (mid-sentence and start-sentence forms)
\def\citet{\@ifstar{\citetstar}{\citetnostar}}
\def\Citet{\@ifstar{\Citetstar}{\Citetnostar}}
%
% No star found. Now test for argument count.
\def\citetnostar%
{\@ifnextchar[{\squarecitet}{\simplecitet}}
\def\squarecitet[#1]%
{\@ifnextchar[{\twocitet[#1]}{\onecitet[#1]}}
\def\Citetnostar%
{\@ifnextchar[{\squareCitet}{\simpleCitet}}
\def\squareCitet[#1]%
{\@ifnextchar[{\twoCitet[#1]}{\oneCitet[#1]}}
%
% Star found. Now test for argument count.
\def\citetstar%
{\@ifnextchar[{\squarecitetstar}{\simplecitetstar}}
\def\squarecitetstar[#1]%
{\@ifnextchar[{\twocitetstar[#1]}{\onecitetstar[#1]}}
\def\Citetstar%
{\@ifnextchar[{\squareCitetstar}{\simpleCitetstar}}
\def\squareCitetstar[#1]%
{\@ifnextchar[{\twoCitetstar[#1]}{\oneCitetstar[#1]}}
%
\makeatother
%
%%% The following actually do the \cite work
%
% The \citet cases (no arg, one arg, and two args)
\def\simplecitet#1%
{\citeauthor{#1}~\citep{#1}}
\def\onecitet[#1]#2%
{\citeauthor{#2}~\citep[#1]{#2}}
\def\twocitet[#1][#2]#3%
{\citeauthor{#3}~\citep[#1][#2]{#3}}
%
% The \citet* cases (no arg, one arg, and two args)
\def\simplecitetstar#1%
{\citeauthor*{#1}~\citep{#1}}
\def\onecitetstar[#1]#2%
{\citeauthor*{#2}~\citep[#1]{#2}}
\def\twocitetstar[#1][#2]#3%
{\citeauthor*{#3}~\citep[#1][#2]{#3}}
%
% The \Citet cases (no arg, one arg, and two args)
\def\simpleCitet#1%
{\Citeauthor{#1}~\citep{#1}}
\def\oneCitet[#1]#2%
{\Citeauthor{#2}~\citep[#1]{#2}}
\def\twoCitet[#1][#2]#3%
{\Citeauthor{#3}~\citep[#1][#2]{#3}}
%
% The \Citet* cases (no arg, one arg, and two args)
\def\simpleCitetstar#1%
{\Citeauthor*{#1}~\citep{#1}}
\def\oneCitetstar[#1]#2%
{\Citeauthor*{#2}~\citep[#1]{#2}}
\def\twoCitetstar[#1][#2]#3%
{\Citeauthor*{#3}~\citep[#1][#2]{#3}}
UPDATE: For author-year citations (i.e., "Harvard style citations"), you must replace the \citep with \citeyearpar. That is, replace the final section of the code above with this section:
Those lines seem to work for me.%%% The following actually do the \cite work
%
% The \citet cases (no arg, one arg, and two args)
\def\simplecitet#1%
{\citeauthor{#1}~\citeyearpar{#1}}
\def\onecitet[#1]#2%
{\citeauthor{#2}~\citeyearpar[#1]{#2}}
\def\twocitet[#1][#2]#3%
{\citeauthor{#3}~\citeyearpar[#1][#2]{#3}}
%
% The \citet* cases (no arg, one arg, and two args)
\def\simplecitetstar#1%
{\citeauthor*{#1}~\citeyearpar{#1}}
\def\onecitetstar[#1]#2%
{\citeauthor*{#2}~\citeyearpar[#1]{#2}}
\def\twocitetstar[#1][#2]#3%
{\citeauthor*{#3}~\citeyearpar[#1][#2]{#3}}
%
% The \Citet cases (no arg, one arg, and two args)
\def\simpleCitet#1%
{\Citeauthor{#1}~\citeyearpar{#1}}
\def\oneCitet[#1]#2%
{\Citeauthor{#2}~\citeyearpar[#1]{#2}}
\def\twoCitet[#1][#2]#3%
{\Citeauthor{#3}~\citeyearpar[#1][#2]{#3}}
%
% The \Citet* cases (no arg, one arg, and two args)
\def\simpleCitetstar#1%
{\Citeauthor*{#1}~\citeyearpar{#1}}
\def\oneCitetstar[#1]#2%
{\Citeauthor*{#2}~\citeyearpar[#1]{#2}}
\def\twoCitetstar[#1][#2]#3%
{\Citeauthor*{#3}~\citeyearpar[#1][#2]{#3}}
Labels:
bibliographies,
bibliography,
examples,
latex,
latex examples,
natbib,
references,
tex,
TeX/LaTeX,
texlatex,
typesetting,
writing
Thursday, September 04, 2008
Course web pages, LaTeX, and Mercurial — Oh, my!
I have been assigned to TA yet another different course for the Autumn 2008 quarter. That was a bummer for me because I have been taking instruction way too seriously, and it has been taking up way too much of my time. However, I've been pretty happy with the results. I've been getting flattering praise and very helpful feedback. More importantly for this post, I've been producing lots of revision-controlled content that can be used for reference or as examples.
The four course web pages that I've produced so far...
I'm really a lot more proud of this work than I thought I'd be. I'm actually looking forward to the new ECE 209 class. It's the youngest group of college students I've taught since a long time ago, and I think it will be interesting. Yesterday I went through and got the lab in order. I put up instructive signs about how to use oscilloscope probes and pin-outs of commonly-used ICs. I numbered all of the tables. I added notes to the function generators telling them how to set them for high impedance output termination. Earlier I went through and repaired all of the phase-shifter circuits (out of 16 circuits, only about 4 were working, but the other 12 could be easily repaired with a little solder and/or a new op-amp IC) and added a little instructive page on how they work. Now all that's left is the actual experience that will make me even more jaded and realize that all of that work was for nothing. :)
Meanwhile though... Lots of free LaTeX examples and circuit references. Yay!
The four course web pages that I've produced so far...
- ECE 209 — Circuits and Electronics (permanent home, OSU home)
- ECE 327 — Electronic Devices and Circuits Laboratory I (permanent home, OSU home)
- ECE 481 — Engineering Ethics (just a grader here) (permanent home, OSU home)
- ECE 557 — Control, Signals, and Systems Laboratory (permanent home, OSU home)
- ece209 Mercurial repository
- ece327 Mercurial repository
- ece481 Mercurial repository
- ece557 Mercurial repository
I'm really a lot more proud of this work than I thought I'd be. I'm actually looking forward to the new ECE 209 class. It's the youngest group of college students I've taught since a long time ago, and I think it will be interesting. Yesterday I went through and got the lab in order. I put up instructive signs about how to use oscilloscope probes and pin-outs of commonly-used ICs. I numbered all of the tables. I added notes to the function generators telling them how to set them for high impedance output termination. Earlier I went through and repaired all of the phase-shifter circuits (out of 16 circuits, only about 4 were working, but the other 12 could be easily repaired with a little solder and/or a new op-amp IC) and added a little instructive page on how they work. Now all that's left is the actual experience that will make me even more jaded and realize that all of that work was for nothing. :)
Meanwhile though... Lots of free LaTeX examples and circuit references. Yay!
Tuesday, August 19, 2008
Building MATLAB images from Makefiles
Recently I beefed up my LaTeX Makefiles to make image generation more automatic. These implicit rules have worked very well for me (note that the indentation is done with TABS — that's important).
I want to point out the MATLAB build line:
Getting back to the more general case, up high in my Makefile, I have something like
Those lines have saved me a lot of time, and I'm pretty happy about them.
That if, if I need a file called FILENAME.eps or FILENAME.pdf, the Makefile will look for FILENAME.m, FILENAME.png, FILENAME.jpg, or FILENAME.tex. Depending on which one it finds, it will run the appropriate command to generate the image I need. Note that I define RESOLUTION=1500 in the top of my Makefile.%.pdf : %.eps
epstopdf $*.eps
%.eps : %.m
matlab -nosplash -nodesktop -r "$*;quit"
%.eps : %.png
convert -density $(RESOLUTION) $*.png $*.eps
%.eps : %.jpg
convert -density $(RESOLUTION) $*.jpg $*.eps
%.eps : %.dvi
dvips $* -D $(RESOLUTION) -E -o $*.eps
%.dvi : %.tex
latex -interaction=nonstopmode $*.tex
rm -f $*.log
rm -f $*.aux
I want to point out the MATLAB build line:
matlab -nosplash -nodesktop -r "$*;quit"That handy line starts up as little of MATLAB as possible and runs a script that contains something like:
After the script finishes, MATLAB exits. It won't get started on any subsequent makes so long as the script file doesn't change or the image isn't deleted.% First, generate a figure somehow
% Next, setup the figure's print proportions
set( gcf, 'PaperType', 'usletter', ...
'PaperOrientation', 'portrait', ...
'PaperPosition', [0.0 3.5 11 3.5] );
% Finally, save the figure as a (color) EPS
saveas( gcf, 'FILENAME.eps', 'epsc2' );
Getting back to the more general case, up high in my Makefile, I have something like
and a little later I make $(TEXIMAGES) a dependency for my document (or something equivalent to that).RESOLUTION=1500
BASETEXIMAGES=$(shell perl -ne \
'/\\includegraphics\s*(?:\[.*?\]|)\s*{\s*(.*?)\s*}/ \
&& do { print "$$1 " \
if (-e "$${1}.tex" || \
-e "$${1}.png" || \
-e "$${1}.jpg" || \
-e "$${1}.m"); };' *.tex)
TEXIMAGES=$(addsuffix .eps,$(BASETEXIMAGES))
Those lines have saved me a lot of time, and I'm pretty happy about them.
Labels:
GNU make,
latex,
latex examples,
Makefile,
MATLAB,
reference,
tex,
TeX/LaTeX,
texlatex,
typesetting
Monday, July 28, 2008
Adding section or subsection to every reference (but not label)
In the form topic, "Full context variable depth references to list labels?," someone wanted to force LaTeX to
It seems to work well and is one of those solutions that TeXnicians would probably do on their own without a second thought and would never document, but it's something complicated-enough that everyone else would tear their hair out searching for it.
- use legal-format lists
- reformat its references to prefix them with the full subsection number (e.g., "2.1-") when inside a subsection and section number (e.g., "2-") otherwise.
I've wrapped lines (by inserting VERY important % characters in special places to make the snippet viewable in this thin blog. As you can see in the original thread, my suggestion looked shorter because the lines were unwrapped.\usepackage{enumitem}
\newlist{legal}{enumerate}{10}
\makeatletter
\setlist[legal]{label*=\arabic*.,
ref=\csname
the\enit@prevlabel
\endcsname\arabic*.}
\newcommand\thesectionlabel{%
\ifnum\value{subsection}=0
\thesection
\else
\thesubsection
\fi}
\newcommand{\thelegal}{\thesectionlabel-}
\makeatother
\usepackage{varioref}
\labelformat{equation}%
{\thesectionlabel-\textup{(#1)}}
\labelformat{figure}{\thesectionlabel-#1}
\labelformat{table}{\thesectionlabel-#1}
It seems to work well and is one of those solutions that TeXnicians would probably do on their own without a second thought and would never document, but it's something complicated-enough that everyone else would tear their hair out searching for it.
Labels:
examples,
latex,
latex examples,
reference,
tex,
TeX/LaTeX,
texlatex,
TeXnician,
typesetting
Subscribe to:
Posts (Atom)