colincaprani.com

Structural Engineering, Bridge Research, Programming, and more…

Entries Comments


Integrating LaTeXdiff with TeXStudio

31 August, 2017 (13:27) | Programming | No comments

Recently I’ve started using LaTeX for my more mathematical writing. Although I’ve been using MS Word + MathType for 15+ years, the frustration of bad typesetting, and the difficulty in changing formatting globally got too much for me. 

I’m using TeXStudio with MiKTeX in a Windows 10 environment (one step at a time…I’ll get to Linux eventually!).

As a postgraduate student supervisor, I make changes to text quite a bit, and MS Word’s Track Changes is very good for highlighting these changes. A tool to accomplish this in LaTeX is LaTeXdiff. Now, of course, since the LaTeX world is free, things aren’t quite as slick and user-friendly for installing as paying $100s for M$ products. So, to get LaTeXdiff up and running, took a little bit of effort, so here’s how I did it.

There are two main parts:

  1. Getting LaTeXdiff installed and working on your machine
  2. Getting a macro to automate things in TeXStudio

Good references for achieving various parts of this are:

However, not one of these worked for me in totality, and parts of the above were unnecessary, hence this post.

Installing LaTeXdiff

Very straightforward:

  1. Install the LaTeXdiff package through the MiKTeX Package Manager
  2. Install Strawberry Perl

You can verify this works by launching the “Perl (command line)” app (or just the usual cmd tool) from the Windows start menu. cd to your current directory with old.tex and new.tex versions of your file. Then execute

1
latexdiff old.tex new.tex > diff.tex

where diff.tex is the file to be written with changes marked in it. Then build the diff.tex to PDF and view something like this:

Integrating with TeXStudio

This was a bit trickier to accomplish, and took some experimentation. In TeXStudio, go to the menu Macros > Edit Macros... and add a new macro, calling it whatever you want (e.g. LaTeXdiff). Set, the macro as a Script style, and paste in the following script, which is also available to copy from PasteBin. Most of the script is for the user dialogs. At the end, it prepares a command line string, which TeXStudio executes in the shell. The stdout is then captured in readAllStandardOutputStr() and written to the diff file in the local directory. The diff file is then compiled and the PDF displayed in TeXStudio viewer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
%SCRIPT
 
var cf = app.getCurrentFileName();
 
var ld = new String(cf);
ld=ld.substring(0,ld.lastIndexOf("/"));
 
information("Select original file");
fileChooser.setDir(ld);
fileChooser.setFilter("TeX files (*.tex)");
fileChooser.exec();
var fold=new String();
fold=fileChooser.fileName();
fold=fold.substring(fold.lastIndexOf("/")+1);
 
information("Select revised file");
fileChooser.setDir(ld);
fileChooser.setFilter("TeX files (*.tex)");
fileChooser.exec();
var fnew=new String();
fnew=fileChooser.fileName();
fnew=fnew.substring(fnew.lastIndexOf("/")+1);
 
information("Select changes tracking file");
fileChooser.setDir(ld);
fileChooser.setFilter("TeX files (*.tex)");
fileChooser.exec(fout);
var fout=new String();
fout=fileChooser.fileName();
fout=fout.substring(fout.lastIndexOf("/")+1);
 
ldfout = ld+"\\"+fout;
 
var cmdstr = new String();
cmdstr = "latexdiff-so "+fold+" "+fnew+" > /dev/null";
var proc = system("cmd /C "+cmdstr,ld);
proc.waitForFinished();
writeFile(ldfout, proc.readAllStandardOutputStr());
app.load(ldfout); // load diff file
buildManager.runCommand("txs:///quick", ldfout);
 
delete(cmdstr);
delete(dialog);
delete(fold);
delete(fnew);
delete(fout);
delete(ld);
delete(ldfout);

IStructE: Australia meets Ireland

14 February, 2017 (23:19) | Engineering | No comments

Prof. Brian Uy, University of Sydney, will give a lecture to the Insitution of Structural Engineers, Republic of Ireland Regional Group on recent advances in steel composite structures in Australasia. Prof. Uy has extensive experience in conducting the research and developing the latest codes of practice for composite structures in Australasia.  He is the Chairman of the Standards Australia Committee BD32 on Composite Structures and a member of BD90 on Bridge Structures which have recently completed new standards on Steel and Composite Structures for buildings and bridges respectively.

Prof Uy has been the Chairman of the Australia Regional Group of the Institution of Structural Engineers (IStructE) since 2012 and the Australian Group of the International Association of Bridge and Structural Engineering (IABSE) since 2015.

The lecture will take place as follows:

  • 21 February 2017
  • Room F14 Newstead Building, UCD, Belfield
  • Admission is FREE and all are welcome.

Back up at last!

25 April, 2015 (05:52) | General | No comments

So this website disappeared for a while, as you may have noticed. In July 2013 I moved to Australia, to the Department of Civil Engineering at Monash University in Melbourne – see me here. It’s been a very busy time since then, and the website got lost in the mix. I’m really pleased to have sorted it out now, and look forward to posting regular updates on all things engineering, bridges, and teaching, as in the past.

I also moved host to allow for unlimited bandwidth, and so this means I can continue to share my lecture notes. In the past I had to stop this because of massive download traffic!

Here’s a pic of the West Gate Bridge – probably the most famous bridge around Melbourne. In a way, this is why I’m here!

West Gate Bridge enjoying a typical Melbourne sunset

Qualitative Analysis

19 April, 2013 (00:21) | Lectures | No comments

Analysing structures without recourse to numbers is vital for engineers to have a basic appreciation of structural behaviour, and to help identify errors in computer input from the output. Dr David Brohn (New Paradigm Solutions and author of Understanding Structural Analysis) has been an important figure in this field since the late 70s and his important benchmark tests of structural understanding. As part of an e-Training course for the Institution of Structural Engineers, Dr Brohn has developed a video series to teach qualitative analysis. The first three of these are freely available and are very useful:

Peter Rice – 20 year Anniversary

25 March, 2013 (22:51) | General | 1 comment

Peter Rice the famous and brilliant Irish engineer died 20 years ago this year. To celebrate his significant contribution to the global profession of structural engineering, a few new publications/broadcasts have been released. These are a must read/watch/listen for any structural engineer, but especially Irish students of structural engineering!

1. Traces of Peter Rice

Arup have produced a fascinating documentary on his work. The film examines Peter’s approach to engineering and to design and shows how his way of working broadened the horizons for both engineers and architects in his lifetime, a legacy that is still relevant today.

2. Traces of Peter Rice (book)

To accompany the Arup exhibition, this book is a gathering of essays in tribute to the life and achievements of a remarkable Irish- born structural engineer Peter Rice (1935-1992), ‘perhaps the most influential of the 20th century’. It can be got here: http://www.amazon.com/Traces-Peter-Rice-Kevin-Barry/dp/1843513862.

3. Remembering Peter Rice

The RTE Radio 1 Arts Tonight documentary can be listed to here. It features a range of well-known architects, but unfortunately, no engineer.

4. Arup Exhibition – Traces of Peter Rice

The exhibition will close in London on 5 April and begin touring France and Ireland, as follows:

The exhibition will tour to the Centre Culturel Irlandais, Paris from the 14 May 2013 until the 28 June 2013 and then to the Farmleigh Gallery, Dublin between 10 October 2013 and 23 December 2013.

The website is here: http://www.arup.com/Home/News/Events_and_exhibitions/Exhibition_Spaces.aspx

5. Timeline of Peter Rice projects

Finally, a wonderful timeline of Peter Rice’s projects is available (taken from here):

« Older entries