Thursday, February 9, 2017

Text Highlighting in Latex

While preparing a manuscript with Latex, it is often useful to highlight the changes made in the current revision with a different color. This can be achieved using the \textcolor command provided by Latex. For example, \textcolor{red}{Hello World} would display the string "Hello World" in red color.

However, the final/published copy of the manuscript does not contain any highlighted text. Therefore, if a large volume of changes were made, it becomes tiresome at the end to find and remove all the individual portions of highlighted text.

This can be circumvented by defining a utility command to switch highlighting on and off as desired. In the following, we define a new Latex command, highlighttext, for this purpose. The command takes only a single argument -- the text that it should highlight.


        % For highlighting changes in this version with red color
    \newcommand{\highlighttext}[1] {\textcolor{red}{#1}}
    % Remove all text highlighting

    % Useful to generate the final version of the PDF
    %\newcommand{\highlighttext}[1] {#1}

In particular, the line

\newcommand{\highlighttext}[1] {\textcolor{red}{#1}}

indicates that when highlighttext is called with an argument, it will change the color of the argument (text) to red. Moreover, if we wish to change the highlight color from red to say, yellow, we only need to change the above line.

When review of the manuscript is over or, in general, when you do not require the highlighted text any more, simply comment out the above line, and uncomment the following:

\newcommand{\highlighttext}[1] {#1}

This version of the command signifies that whenever highlighttext is called with an argument, the argument (text) is returned as it is -- no processing (e.g., coloring) over it is done. Note that only one of these two command definitions should be enabled at any given time -- the other should be commented out.

What do you think of this technique? Did the pair of commands make text highlighting easier for you? Or do you use any better approach? Let the world know in the comments!

Sunday, January 1, 2017

Welcome, 2017!

Dear Readers and Followers,

Wish you and your family a very happy and prosperous New Year! May this new year dawns with the promises of a brighter tomorrow. #HNY2017

Friday, January 1, 2016

Happy New Year

A very happy and prosperous new year to you all! Hope you had a great year in 2015, and wish you have a still better one in 2016! May you do excellent research in this year, and may your citations increase manifold :D

Saturday, November 28, 2015

Book on Opportunistic Mobile Networks

Opportunistic Mobile Networks: Advances and Applications is our forthcoming book to be published by Springer in 2016. This book is a result of our years of experience in research and development in this domain. #TheOMNBook, if you may say, deals with fundamental challenges in OMNs as well as contemporary research issues. These include, but not limited to, routing, mobility, cooperation, heterogeneity, and emotions. An entire chapter is dedicated to protocol development and testing using the ONE simulator.

#TheOMNBook is shaped in a way to cater both beginning and advanced level readers. Contextual examples are provided to ensure better understanding of related topics. The chapters come with plenty of hands-on exercises. Several illustrations and other visual elements are used to make reading the book a pleasant experience. Whether you are a seasoned researcher looking for novel cross-dimensional ideas or a beginner to this field, give #TheOMNBook a try!

Learn more about our book at our website. Also, subscribe to the email list and get notified about the book's publication and other updates.

Friday, July 17, 2015

IllegalArgumentException in Simulations

At times, users have reported of runtime exceptions while running a simulation that uses PRoPHET. The error signature looks like the following.

Exception in thread "main" java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(Unknown Source)
at java.util.TimSort.mergeAt(Unknown Source)
at java.util.TimSort.mergeCollapse(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.ArrayList.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)

It may be noted that the default sorting algorithm has changed since Java 7 — rather than Merge sort, Tim sort is now used by default. However, it seems like it is possible to override the default sorting algorithm in Java using the following argument to the JVM.


The execution command in the (or one.bat) file should be updated with the above argument to something like this:

java -Xmx512M -Djava.util.Arrays.useLegacyMergeSort=true -cp .:lib/ECLA.jar:lib/DTNConsoleConnection.jar core.DTNSim $*

I, however, do not have a Java 7 installation, and therefore, could not test it. Users facing the aforementioned runtime exception can try it out and share their experiences here.