[texhax] Word vs. LaTeX questions (was latex in social sciences?)
Dimitri Antoniou
dimitri at risc1.aecom.yu.edu
Sun May 7 21:25:28 CEST 2006
"flom at ndri.org" asked 2 questions:
> Another thing that can be done in Word is track changes.
Have you checked the script latexdiff from CTAN?
Given 2 latex source files, it produces a 3rd latex file
with additions/deletions highlighted in color.
> for example, if I wanted to cite a work by Karl,
> but only knew that it had the author Berry and the word LaTeX,
> I could hit alt-t, then enter, then berry latex and
> it would bring up every item in my bibliography that had both these things.
You can do this easily if you have perl in your system.
Plain grep will find only the line that matched,
while we need the whole bibitem.
If you call the following perl script eg "bibgrep", you say
bibgrep keyword1 keyword2 ... (keywords are separated by spaces)
and it will return the bibitems that matched.
It will work in linux, to use it in windows you have to slightly
modify it, because DOS has different end-of-line concept.
At the bottom, I show how I call it from inside vim
so that it shows the matches in a vim preview window.
----------------------------
#!/usr/bin/perl -w
$/ = '';
$bibfile = "Full_path_to_your_Bibliography_file";
open BFILE, $bibfile or die "cannot open $bibfile";
BIBITEM: foreach $bibitem (<BFILE>) {
foreach $word (@ARGV) {
next BIBITEM unless ( $bibitem =~ m/$word/i );
}
print $bibitem;
}
----------------------------
To run the above script from inside vim,
add the following lines in your .vimrc
and type
,b followed by the keywords you want to search for.
It will show the matches in a vim preview window.
----------------------------
map ,b :Bibgrep
command -nargs=* Bibgrep call SearchBib(<f-args>)
function SearchBib(first, ...)
let keywords = a:first
for morekeywords in a:000
let keywords = a:first . ' ' . morekeywords
endfor
cexpr system('/usr/local/bin/bibgrep' . ' ' . keywords)
copen
endfunction
----------------------------
--
Dimitri Antoniou
Department of Biophysics
Albert Einstein College of Medicine
More information about the texhax
mailing list