Skip to content

Instantly share code, notes, and snippets.

@kauplan
Last active May 25, 2020 12:45
Show Gist options
  • Save kauplan/e1bb6fc27b079421d41ecf6d46aee8e1 to your computer and use it in GitHub Desktop.
Save kauplan/e1bb6fc27b079421d41ecf6d46aee8e1 to your computer and use it in GitHub Desktop.
`\ifx`を含むcontrol sequenceを入れ子にすると、外側の`\ifxxx`と内側の`\else`が結びついてしまうため、エラー
% -*- coding: utf-8 -*-
\documentclass[dvipdfmx,uplatex]{jsarticle}
\usepackage[deluxe]{otf}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
%%%%%
\newcommand{\ifempty}[1]{%
\edef\tempval{#1}%
\ifx\tempval\empty%
}
\def\sampleflag{Y}
\newcommand{\samplecommand}{SAMPLE}
\ifempty{\sampleflag}%
\renewcommand{\samplecommand}[1]{%
\ifempty{#1}%
EMPTY
\else%
NOT EMPTY %← ./main.tex:24: LaTeX Error: Missing \begin{document}.
\fi%
}%
\fi
%%%%%
\begin{document}
本文\par
\samplecommand
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment