Table of Contents

,

LaTeX Tricks

$\LaTeX$ is Leslie Lamport's $\TeX$, in case you don't know it, as I used to.

Remove all comments using find-and-replace

This method may depend on writing habits. I place each sentence in a separate line.

Using this regular expression (?<!\\)%[^%]+ to match contents starting with %, excepting

Replace matches with %.

Be careful with figures in latex

\includegraphics is not destructive, meaning that it only hides part of the figure rather than delete it from the final output.

See remove clipped image sections from included PDF.

See How can I crop included PDF documents?

Also, the original filename can be retrieved with some magics. See Is the filename of an image preserved in the final PDF?

# My solution of Destructive clipping of \includegraphics

Not yet have a good and easy solution…

https://ctan.org/pkg/pdfcrop

Got a pile of the following warning:

PDF inclusion: multiple pdfs with page group included in a single page

Solution: adding \pdfsuppresswarningpagegroup=1 to the top of your file (orignal source).

Got the following warning when including *.pdf figures:

PDF inclusion: found PDF version <1.7>, but at most version <1.5> allowed

Solution: adding \pdfminorversion=6 to the preamble (original source).

Collaborate and Add Comments in LaTeX Source

I found the comments Overleaf.com can be lost if the source file is moved or edited externally. As explained in this link. So, if we want to use Overleaf's comment system to keep track of the discussion, we cannot move the files away from the website, and we'd better not to edit it locally either. But I feel this this is too restricted.

I now think overleaf's comments and tracing system is not quite reliable. It is not based on the source file. Not like MS Word, where all tracings and reviews are save in the single .docx file.

I suggest we directly discuss in the source code, by distinguishing the discussion with special format like colors or fonts. This can be easily manipulated by defining a command like:

\newcommand{\phSays}[1]{{\large\color{blue}[[Hao: #1]]}}

Then we can just insert a comment in the source code by \phSays{blablabla}, and it will show up after compiling. In this way, later, if we need to share only compiled PDF files with others, we can just comment them out using % redefine the special command to an empty command as:

\newcommand{\phSays}[1]{}

and almost never lost any discussion;
if we need to share source files but not willing to reveal internal discussions, just search and delete all \phSays{…} segments.

Some other useful links:

Packages

hyperref

Overwritten the settings by elsarticle class.

https://tex.stackexchange.com/a/246401
As Augustin has already analyzed in his answer, class elsarticle defines the colors of all link types to blue. This is done via \AtBeginDocument. A later \AtBeginDocument can again overwrite the color settings as shown in the following example.

latexdiff

Got the following error at multiple places for no clear reason during compiling using pdflatex,

ERROR: Extra }, or forgotten \endgroup.

TL;DR: The solution is to add the following line at the very beginning of the revised .tex file,

\RequirePackage[2019/11/18]{latexrelease}  % to use an old release of LaTeX

Longer answer: A $\LaTeX$ update has introduced some incompatibilities with \usepackage{ulem}, therefore the \sout{} and \uwave{} doesn't work. Actually just including the ulem package will casue the problem, even if one doesn't use any command from it.

For more details, see https://tex.stackexchange.com/a/574311.