Repository for Ideas & Research
Open Source GIS, Hydrologic Modeling, Optimization

LaTeX

1   Font for number domains

Use \mathds from the dsfont package.

\mathds{R}^n

2   tikzscale doesn’t work when tikz figures are externalized by name

tikzscale not working with externalize using named only

tikzscale and \tikzsetnextfilename do not work together

Scale tikz figure to a percentage of \textwidth

Use \begin{tikzpicture}[scale=0.5\textwidth/240cm] or \begin{tikzpicture}\begin{axis}[width=0.5\textwidth] instead of \includegraphics[width=0.5\textwidth].

3   \cite and \citep don’t work inside changes commands when used with ulem

Change tracking while using bilatex-apa results in an error

ulem commands don’t work with \cite and \citep. A workaround is to redefine \cite and \citep as follows:

\let\origcite\cite
\let\origcite\citep
\renewcommand\cite[1]{\mbox{\origcite{#1}}}
\renewcommand\citep[1]{\mbox{\origcitep{#1}}}

Redefine these commands only for marked manuscripts because I don’t want excessively long text boxes in the final version. For example,

\newif\ifmarked
\markedtrue

\ifmarked
  \usepackage[markup=underlined]{changes}
  \let\origcite\cite
  \let\origcitep\citep
  \renewcommand\cite[1]{\mbox{\origcite{#1}}}
  \renewcommand\citep[1]{\mbox{\origcitep{#1}}}
\else
  \usepackage[final]{changes}
\fi

However, I still have an issue with the above approach because, even in a marked version, the new \cite and \citep should be used only inside changes commands and the original version of these commands should be used elsewhere. An ugly hack is provided below:

\newif\ifmarked
\markedtrue

\ifmarked
  \usepackage[markup=underlined]{changes}
  \let\origcite\cite
  \let\origcitep\citep
  \newcommand\redefineforchanges{%
    \renewcommand\cite[1]{\mbox{\origcite{##1}}}%
    \renewcommand\citep[1]{\mbox{\origcitep{##1}}}}
  \newcommand\redefineforothers{%
    \let\cite\origcite%
    \let\citep\origcitep}
\else
  \usepackage[final]{changes}
  \newcommand\redefineforchanges{}
  \newcommand\redefineforothers{}  
\fi

Use \redefineforchanges before using \cite and \citep inside changes commands and restore the original version of these commands later:

\redefineforchanges\added{\cite{Cho.2016} proposed a new approach...}\redefineforothers

An alternative approach is to define separate cite commands for changes commands:

\newif\ifmarked
\markedtrue

\ifmarked
  \usepackage[markup=underlined]{changes}
  \newcommand\changescite[1]{\mbox{\cite{#1}}}
  \newcommand\changescitep[1]{\mbox{\citep{#1}}}
\else
  \usepackage[final]{changes}
  \let\changescite\cite
  \let\changescitep\citep
\fi

Use them like this:

\added{\changescite{Cho.2016} proposed a new approach...}

4   Redefining an existing command using the same command inside

Using \expandafter for macro redefinitions

A Tutorial on \expandafter

5   The TikZ trapezium node has a sizing bug

Why trapez shape width changes with text?

6   TikZ externalization conflicts with the endfloat package

pdflatex -shell-escape main would not run successfully if main.tex includes \usepackage{endfloat}.

7   lineno numbering issue

Why doesn’t lineno number a paragraph when it is followed by an “align” equation environment without a space?

\newcommand*\patchAmsMathEnvironmentForLineno[1]{%
  \expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
  \expandafter\let\csname oldend#1\expandafter\endcsname\csname end#1\endcsname
  \renewenvironment{#1}%
     {\linenomath\csname old#1\endcsname}%
     {\csname oldend#1\endcsname\endlinenomath}}% 
\newcommand*\patchBothAmsMathEnvironmentsForLineno[1]{%
  \patchAmsMathEnvironmentForLineno{#1}%
  \patchAmsMathEnvironmentForLineno{#1*}}%
\AtBeginDocument{%
\patchBothAmsMathEnvironmentsForLineno{equation}%
\patchBothAmsMathEnvironmentsForLineno{align}%
\patchBothAmsMathEnvironmentsForLineno{flalign}%
\patchBothAmsMathEnvironmentsForLineno{alignat}%
\patchBothAmsMathEnvironmentsForLineno{gather}%
\patchBothAmsMathEnvironmentsForLineno{multline}%
}

8   elsarticle corresponding author issue

Elsarticle frontmatter corresponding author

\makeatletter
\def\@author#1{\g@addto@macro\elsauthors{\normalsize%
    \def\baselinestretch{1}%
    \upshape\authorsep#1\unskip\textsuperscript{%
      \ifx\@fnmark\@empty\else\unskip\sep\@fnmark\let\sep=,\fi
      \ifx\@corref\@empty\else\unskip\sep\@corref\let\sep=,\fi
      }%
    \def\authorsep{\unskip,\space}%
    \global\let\@fnmark\@empty
    \global\let\@corref\@empty  %% Added
    \global\let\sep\@empty}%
    \@eadauthor={#1}
}
\makeatother

9   Tikz externalize not working when jobname is specified for main document

Tikz externalize not working when jobname is specified for main document


Wed Sep 21 23:00:11 2016 EDT by Unknown
Parsing time: 0.045 seconds
XHTML . CSS . Powered by Uniqki!