How to Add an Auto Version Number in Latex? - latex

This question Add a version number to the title of a LaTeX document spurred my curiosity:
How do you add an auto-version number in Latex?
( So one is not doing this: {\bf Version:} 1.2 and then later {\bf Version:} 1.2 1.3) ?

\usepackage[nofancy]{svninfo}
\svnInfo $Id: viperdefects.tex 125 2007-05-29 16:29:07Z longborb $
\svnKeyword $URL: file:///F:/Stuff/Repository/Development/Essays/Viper/viperdefects.tex $
If you use Subversion, the above code is an example of what you can do. SVN updates the information as you update the file, but beware: only if you up the containing file. It doesn't track updates elsewhere in the tree.
However, I get the feeling that this is now considered a bit old-fashioned; the modern trend is to DVCSs, where there isn't really a valid concept of a linearly incrementing version number.

If you're using Windows, you can install Tortoise SVN and Collabnet Subversion Server. These tools work fine with the svn-multi package in LaTeX to produce the revision/version numbers that you need.

Related

Answer list in R/exams distributed by several columns to save paper space

I would like to configure the answer list in R/exams to be distributed by columns:
A. Answer 1. C. Answer 3.
B. Answer 2. D. Answer 4.
In LaTeX, I have used the multicol package. Is that possible with R/exams as well?
The R/exams interfaces intended for producing PDF files for printing on paper are exams2pdf() and exams2nops() (which is built on top of exams2pdf()). Both of these use LaTeX in the background and allow to tweak the environment that is used for rendering the answer list. So the answer is: Yes, you can also use {multicols} environment from the multicol LaTeX package for this.
More specifically, in the LaTeX code your answer list will be written as:
\begin{answerlist}
\item Answer 1.
\item Answer 2.
\item Answer 3.
\item Answer 4.
\end{answerlist}
The rendering of this {answerlist} then depends on the definition of this environment in the header of the document. The default in exams2nops() as well as the demo templates for exams2pdf() shipped along with the package is:
\newenvironment{answerlist}%
{\renewcommand{\labelenumii}{(\alph{enumii})}\begin{enumerate}}%
{\end{enumerate}}
In short, this simply uses the standard {enumerate} environment and switches the counter to (\alph{...}) formatting, i.e., (a), (b), .... In exams2nops() this yields the following output by default:
Alternatively, you can (re-)define this environment in the following way which uses a {multicols}{2} layout and switches the formatting of the counter to A., B., ...
\newenvironment{answerlist}%
{\renewcommand{\labelenumii}{\Alph{enumii}.}\begin{multicols}{2}\begin{enumerate}}%
{\end{enumerate}\end{multicols}}
When you are using exams2pdf() you can simply define the {answerlist} environment like this in the LaTeX master template that you pass to exams2pdf(..., template = ...).
And when you are using exams2nops() you can re-define the {answerlist} environment on-the-fly in the header:
multicol <- "\\renewenvironment{answerlist}{\\renewcommand{\\labelenumii}{\\Alph{enumii}.}\\begin{multicols}{2}\\begin{enumerate}}{\\end{enumerate}\\end{multicols}}"
exams2nops(..., header = multicol)
This yields:
Depending on the typical length of the items in your answer list you might, of course, also use more columns, e.g., {multicols}{4}.
Furthermore, there is also the built-in option exams2nops(..., twocolumn = TRUE) that switches the layout of the entire document to two columns (as opposed to only the answer list). A demo screenshot is included below.
Finally, some more variations that use the LaTeX environments {paralist} or {enumitem} instead of {multicols} are discussed in this thread in the R/exams forum on R-Forge: https://R-Forge.R-project.org/forum/forum.php?thread_id=33823&forum_id=4377&group_id=1337.

How do I cite the title of an article in LaTeX?

I'm using LaTeX and BibTeX for an article, and I want to able to cite the title of an article I reference. What is the command to do this?
I'm using \bibliographystyle{chicago} and it does not appear to be \citeT{}, \citetitle{} or \citeTitle{}
#Norman, and the various commenters, are correct in that it would be difficult to do this with bibtex and other tools. But, there is an alternative. Biblatex does allow this through the command \citetitle. Also, if you really want to, the formatting drivers in biblatex are easily readable and modifiable, but only if you feel the need. Unfortunately, it is not part of any distribution, yet, so it has to be downloaded and installed.
Just type in the title. Even natbib, the most powerful widespread BibTeX package, is not powerful enough to do what you want out of the box. Trying to get BibTeX to extract the title for you, by means of a LateX command, is possible, but it would require that you
Design a new format for bibliography items that is incompatible with existing formats.
Write your own custom .bst file, using the very strange postfix language that is used only by BibTeX, to be compatible with your new format.
Write a new LaTeX command to pull the title information out of the new format.
Speaking as someone who has written several custom bst files as well as a replacement for BibTeX, it's just not worth fooling with. After all, if you are citing the paper, you probably know the title anyway.
EDIT: If you have to do this with multiple papers, I would try to cheat. Extend the bst file so that it writes into the bbl file a command that writes into the aux file the title associated with each bibkey. You can model the bbl command on \label and the actual title-citing command on \ref.
This is how I solve the title issue for cited papers:
In the preamble
include Natbib:
\usepackage[sort&compress]{natbib}
If you want to cite a TITLE instead of an author in the text you define the title like this in the preamble:
\defcitealias{Weiser1996designingcalm}{Designing Calm Technology}
Note:
You need to have a bibtex item (for the title ''Designing Calm Technology'') with the key {Weiser1996designingcalm}.
In the paper where you want to write the cited paper's title
\citetalias{Weiser1996designingcalm}
this results in => Designing Calm Technology (i.e. the text you specified with the \defcitealias command above)
or
\citepalias{Weiser1996designingcalm}
that results in => (Designing Calm Technology) (i.e. title with parenthesis)
This question is old and maybe \citefield was not around back in the days, but now it works like charm for this kind of problems:
\documentclass[varwidth]{standalone}
\usepackage{biblatex}
\begin{filecontents}{\jobname.bib}
#article{example,
title = {NAME OF PAPER},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\citefield{example}{title}
\end{document}
Got it from this question.
Thanks to Anders for the hint. \defcitealias seems to be the way to go.
Bibtex produces a .bbl file which contains the bibliography entries. something like that
\bibitem[\protect\citeauthoryear{Andrienko
{\itshape{et~al.}}}{2003}]{Andrienko2003}
Andrienko, G., Andrienko, N., and Voss, H., 2003. {GIS for Everyone: The
CommonGIS Project and Beyond}. {\itshape {In}}: {\itshape {Maps and the
Internet}}., 131--146 Elsevier.
I use Eclipse, which is free and that you may already have to apply regular expressions in this file when needed. '\R' acts as platform independent line delimiter. Here is an example of multi-line search:
search:
\\bibitem.*(\R.*)?\R?\{([^{]*)\}\R^[^\\].*\d\d\d\d\.\s([^\.]*\R?[^\.]*)\R?.*\R?.*
and replace:
\\defcitealias{$2}{$3}
(For myself I use \\bibitem.*(\R.*)?\R?\{([^{]*)\}$\R^([^\\].*[^\}]$\R.*$\R.*) to get all the item text)
Et produces a series of \defcitealias that can be copypasted elsewhere:
\defcitealias{Andrienko2003}{{GIS for Everyone: The
CommonGIS Project and Beyond}}
Finally, this can be used to build a custom command such as:
\newcommand{\MyCite}[1]{\citet*{#1}. \citetalias{#1}.}
Used as \MyCite{Andrienko2003} and producing: Andrienko et al. (2003). GIS for Everyone: The CommonGIS Project and Beyond.

Add a version number to the title of a LaTeX document

The title section of my LaTeX documents usually look like
\title{Title}
\author{Me}
%\date{} %// Today's date will appear when this is commented out.
\begin{document}
\maketitle
I'd really like to add another line in the title section for a version number:
\title{Title}
\author{Me}
\version{v1.2}
%\date{} %// Today's date will appear when this is commented out.
\begin{document}
\maketitle
It doesn't necessarily have to be a command named version, but how can I get a version number to appear after the date (which is after the author)? I can manually set the version number.
So:
Title
Me
4/13/2010
v1.2
The easiest way to do exactly what I wanted to do was to simply use:
\title{Title}
\author{Me}
\date{\today\\v1.2}
\begin{document}
\maketitle
My answer is probably too late for the original thread, but Latex has a very interesting package called vrsion (there is no 'e'), which is part of the standard distribution. Essentially, it numbers the .dvi file, i.e the number is increased every time Latex is run.
Personally, I use this as a simple work around for the lack of a human-friendly document version number from Git. Not ideal, but sometimes I have multiple copies of my documents and it helps avoid some confusion.
For many version control systems, the checkin and checkout programs will expand certain strings in the documents into metadata the version control system has about the system, including the version number.
If you include these strings in the body of Tex definitions, then you can use them in your documents.
It's hard to say more without knowing which version control system you are using, but CTAN has the vc bundle, and rcs.sty is nice to use, for folks still using not only non-distributed, but not even concurrent VC...
Once you've got the strings (oh, I see you said manual entry is OK), you can then typeset this using
\title{Title\\\normalsize Version \versionnumber}
If you really want the author in between, then you can't use \title and \author together in the usual way - you should put your name on another line in the \title command.
If you have your document controlled inside a git repository, then this can be achieved using the gitinfo package. If correctly configured (which involves adding post-hooks to your git system), you can simply use \gitVtag to call the version number (as embodied in a git tag) or e.g. \gitAbbrevHash to get the abbreviated hash of the current commit of the repo.
Simple manual method:
Create a file called (say) version.tex:
\providecommand{\versionnumber}{3.0.1}
Where you need to use it:
\input{version}
\title{Title\\\normalsize Version \versionnumber}
This will give you a single common place in your project or projects to update the version manually.
If you need to display the version number only in the titlepage, you just need to modify it using
\begin{titlepage}
...
Version 1.x
...
\end{titlepage}
after issuing the command \maketitle.
Otherwise, if you need to recall it in several times throughout the document, it's better to define a variable:
\def\Version#1{\def\version{#1}}
so that you define the version number with \Version{} and recall it with \version.
Take a look at the packages rcsinfo and rcs. They include keys for extracting data from RCS tags within your document, so that will work if you are using CVS. I found this in The LaTeX Companion, pg 837. Something that works with your VCS of choice may have been written in the meantime.
To provide a \version command like \author, you'd do:
\let\theversion=\relax
\providecommand{\version}[1]{\renewcommand{\theversion}{#1}}
If you're not using a titlepage environment, you can redefine \maketitle itself. Look in article.cls (or whatever class file you're using), copy-and-paste, and insert \theversion whereever and however you want. If you want to check for a version number before putting in the title, do something like:
\def\maketitle{%
% ... stuff copied from original class file...
\ifx\theversion\relax
% do nothing if there is no version defined
\else\bfseries\theversion% set the version
\fi
If you don't need it in the title per se you could add it as a footnote to the date (both of those properties related to the freshness of the resource so it makes some sense to put them together.
\title{My article}
\version{v1.2}
\date{\today\thanks{\theversion}}
I use the package vhistory for a changelog table at the beginning of my documents.
\subject{Institute for nice formatted docs}
\title{My important document}
\subtitle{\vhCurrentVersion, \vhCurrentDate}
\author{Me}
\date{} % Activate to display a given date or no date (if empty)
\begin{document}
\maketitle
\clearpage
\begin{versionhistory}
\vhEntry{v0.1}{17.05.2019}{Me}{First release}
\vhEntry{v0.2}{12.08.2019}{Someone}{Rewrite of chapter 2 ...}
\vhEntry{v0.3}{04.03.2021}{Another editor}{Change after feedback of ...}
\end{versionhistory}
\tableofcontents
[...]
\end{document}
With the following commands you get at any position the current version and the current date, which can be used in the title section.

How to manually equalize columns in an IEEE paper if using BibTex?

IEEE conference publications in two-column format require authors to manually equalize the lengths of the columns on the last page of the final submission. I have typically done this by inserting a \newpage where necessary -- which usually ends up being somewhere amidst my (manually entered) references.
However, I have recently begun using BibTeX to manage references, and have now run into a problem: my last page contains only a few (generated) references, and I can't figure out how to manually equalize the columns.
The last page is the tail end of what is generated by:
\bibliographystyle{IEEEtran}
\bibliography{IEEEabrv,library}
Any ideas on how I can equalize the columns while continuing to use BibTeX?
I have submitted to both ACM and IEEE conferences and the easiest thing for me has been using:
\usepackage{flushend}
I've heard it doesn't always work well, but it's been great for me
http://www.ctan.org/pkg/flushend
I went back to RTFM again, and it turns out this is addressed right in "How to Use the IEEEtran LaTeX Class" by Michael Shell (maintainer). Section XIV notes that IEEEtran helpfully provides the \IEEEtriggeratref{} command for just this purpose. By default, it fires a \newline at the given BibTeX reference number. You can even change the command to fire with \IEEEtriggercmd{}.
It can also be done by using the balance package. You simply include the balance package in the preamble (\usepackage{balance}) and insert \balance some place on the last page of your document (for instance right in front of the references). However, I'm not sure if it's working if the last page (both columns) is completely full of references...
IEEE requires authors to equalize the lengths of the columns on the last page.
ACM makes us do this too. I just wind up inserting \vfill\break by hand either in the main text or somewhere in the .bbl file, wherever it makes the columns balance. By the time camera-ready copy goes to ACM, they want the .bbl file inlined by hand anyway, so tinkering by hand does not present an additional hardship.
The reference-number trick might be nice except I never use numbered references :-)
The multicols environment works only if you're luck and your last page comes out exactly as bibliography.
It would be extremely good (and not so difficult) if some enterprising hacker would build the "balance the two columns in the last page" functionality straight into LateX's \output routine. The flexibility is there in the underlying engine, and it would make a lot of people happy.
Not sure if multicol conflicts with bibtex at all, and I don't have time to check, sorry. But try this:
use the multicol package:
\usepackage{multicol} in your preamble, then:
\begin{multicols}{2}
\bibliographystyle{IEEEtran}
\bibliography{IEEEabrv,library}
\end{multicols}
Multicol automatically balances columns. I would recomend using it through out your document, instead of using the .cls or .sty's twocolumn option.

How do I "diff" multiple files against a single base file?

I have a configuration file that I consider to be my "base" configuration. I'd like to compare up to 10 other configuration files against that single base file. I'm looking for a report where each file is compared against the base file.
I've been looking at diff and sdiff, but they don't completely offer what I am looking for.
I've considered diff'ing the base against each file individually, but my problem then become merging those into a report. Ideally, if the same line is missing in all 10 config files (when compared to the base config), I'd like that reported in an easy to visualize manner.
Notice that some rows are missing in several of the config files (when compared individually to the base). I'd like to be able to put those on the same line (as above).
Note, the screenshot above is simply a mockup, and not an actual application.
I've looked at using some Delphi controls for this and writing my own (I have Delphi 2007), but if there is a program that already does this, I'd prefer it.
The Delphi controls I've looked at are TDiff, and the TrmDiff* components included in rmcontrols.
For people that are still wondering how to do this, diffuse is the closest answer, it does N-way merge by way of displaying all files and doing three way merge among neighboors.
None of the existing diff/merge tools will do what you want. Based on your sample screenshot you're looking for an algorithm that performs alignments over multiple files and gives appropriate weights based on line similarity.
The first issue is weighting the alignment based on line similarity. Most popular alignment algorithms, including the one used by GNU diff, TDiff, and TrmDiff, do an alignment based on line hashes, and just check whether the lines match exactly or not. You can pre-process the lines to remove whitespace or change everything to lower-case, but that's it. Add, remove, or change a letter and the alignment things the entire line is different. Any alignment of different lines at that point is purely accidental.
Beyond Compare does take line similarity into account, but it really only works for 2-way comparisons. Compare It! also has some sort of similarity algorithm, but it also limited to 2-way comparisons. It can slow down the comparison dramatically, and I'm not aware of any other component or program, commercial or open source, that even tries.
The other issue is that you also want a multi-file comparison. That means either running the 2-way diff algorithm a bunch of times and stitching the results together or finding an algorithm that does multiple alignments at once.
Stitching will be difficult: your sample shows that the original file can have missing lines, so you'd need to compare every file to every other file to get the a bunch of alignments, and then you'd need to work out the best way to match those alignments up. A naive stitching algorithm is pretty easy to do, but it will get messed up by trivial matches (blank lines for example).
There are research papers that cover aligning multiple sequences at once, but they're usually focused on DNA comparisons, you'd definitely have to code it up yourself. Wikipedia covers a lot of the basics, then you'd probably need to switch to Google Scholar.
Sequence alignment
Multiple sequence alignment
Gap penalty
Try Scooter Software's Beyond Compare. It supports 3-way merge and is written in Delphi / Kylix for multi-platform support. I've used it pretty extensively (even over a VPN) and it's performed well.
for f in file1 file2 file3 file4 file5; do echo "$f\n\n">> outF; diff $f baseFile >> outF; echo "\n\n">> outF; done
Diff3 should help. If you're on Windows, you can use it from Cygwin or from diffutils.
I made my own diff tool DirDiff because I didn't want parts that match two times on screen, and differing parts above eachother for easy comparison. You could use it in directory-mode on a directory with an equal number of copies of the base file.
It doesn't render exports of diff's, but I'll list it as a feature request.
You might want to look at some Merge components as what you describe is exactly what Merge tools do between the common base, version control file and local file. Except that you want more than 2 files (+ base)...
Just my $0.02
SourceGear Diffmerge is nice (and free) for windows based file diffing.
I know this is an old thread but vimdiff does (almost) exactly what you're looking for with the added advantage of being able to edit the files right from the diff perspective.
But none of the solutions does more than 3 files still.
What I did was messier, but for the same purpose (comparing contents of multiple config files, no limit except memory and BASH variables)
While loop to read a file into an array:
loadsauce () {
index=0
while read SRCCNT[$index]
do let index=index+1
done < $SRC
}
Again for the target file
loadtarget () {
index=0
while read TRGCNT[$index]
do let index=index+1
done < $TRG
}
string comparison
brutediff () {
# Brute force string compare, probably duplicates diff
# This is very ugly but it will compare every line in SRC against every line in TRG
# Grep might to better, version included for completeness
for selement in $(seq 0 $((${#SRCCNT[#]} - 1)))
do for telement in $(seq 0 $((${#TRGCNT[#]} - 1)))
do [[ "$selement" == "$telement" ]] && echo "${selement} is in ${SRC} and ${TRG}" >> $OUTMATCH
done
done
}
and finally a loop to do it against a list of files
for sauces in $(cat $SRCLIST)
do echo "Checking ${sauces}..."
loadsauce
loadtarget
brutediff
echo -n "Done, "
done
It's still untested/buggy and incomplete (like sorting out duplicates or compiling a list for each line with common files,) but it's definitely a move in the direction OP was asking for.
I do think Perl would be better for this though.

Resources