LaTeX

1   Not-so-frequently asked questions for LaTeX

ifaq.pdf (source)

2   Superscript symbols

Alternatives to asterisk and star for superscripts

  1. *
  2. \dagger
  3. \ddagger
  4. \mathsection
  5. \mathparagraph
  6. \|
  7. **
  8. \dagger\dagger
  9. \ddagger\ddagger

3   Mid-point in TikZ

Path to midpoint of other path

Find the mid-point between (A) and (B), and define it as (C):

\draw (A)--coordinate[midway](C) (B);

or

\usetikzlibrary{calc}

\coordinate (C) at ($(A)!0.5!(B)$);

4   TikZ to SVG

https://github.com/HuidaeCho/tikz2svg

5   Math-mode fonts

What are all the font styles I can use in math mode?

6   Font for number domains

Use \mathds from the dsfont package.

\mathds{R}^n

7   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].

8   \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...}

9   Redefining an existing command using the same command inside

Using \expandafter for macro redefinitions

A Tutorial on \expandafter

10   The TikZ trapezium node has a sizing bug

Why trapez shape width changes with text?

11   TikZ externalization conflicts with the endfloat package

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

12   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}%
}

13   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

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

Tikz externalize not working when jobname is specified for main document

15   References