Skip to main content

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 to be highlighted.

    \usepackage{color}

  % 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!

Comments

Post a Comment

Popular posts from this blog

The ONE KB has a new home

The ONE Knowledge Base is now hosted at http://theonekb.pythonanywhere.com/ If you are unaware, the ONE KB allows you to search the old email archives of the simulator's community. Therefore, if you have any question related to simulation, you may query the existing database at the above link. Chances are good that your question might already have been answered previously. If not, you can still post an email to the community's mailing list. Have you tried the ONE KB already? How was your experience? Was it helpful? Let me know in the comments!

SeeR: Simulated Annealing-based Routing in Opportunistic Mobile Networks

Conceptual architecture of SeeR Opportunistic Mobile Networks (OMNs) are characterized by intermittent connectivity among nodes. In many scenarios, the nodes attempt at local decision making based on greedy approaches, which can result in getting trapped at local optimum. Moreover, for efficient routing, the nodes often collect and exchange lot of information about others. To alleviate such issues, we present SeeR, a simulated annealing-based routing protocol for OMNs. In SeeR, each message is associated with a cost function, which is evaluated by considering its current hop-count and the average aggregated inter-contact time of the node. A node replicates a message to another node, when the latter offers a lower cost. Otherwise, the message is replicated with decreasing probability. Moreover, SeeR works based solely upon local observations. In particular, a node does not track information about other nodes, and, therefore, reduces the risk of privacy leaks unlike m