0

In the first version of the answer to my question Gödel codes with rounded Cornes?, Sandy G offered the following solution:

\newcommand{\godel}[1]{{}\mathbin{\vcenter{\hbox{\tikz{
                    \node[inner ysep=-1pt, inner xsep=3pt](M){$#1\strut$};
                    \draw[rounded corners=.5mm]([xshift=-1mm]M.north east)--(M.north east)--++(0,-.1);
                    \draw[rounded corners=.5mm]([xshift=1mm]M.north west)--(M.north west)--++(0,-.1);
    }}}}{}}

The solution is quite satisfactory for my document, except that many errors are produced, so that the document does not compile, if I put $\godel{A}$ in the title of a section. I tried two ways to protect it, via. $\protect\godel{A}\protect$ and $\protect\godel[thick]{A}$.

Are there other ways to protect $\godel{A}$ in section titles which may help me out?

Sandy G
  • 42,558
  • 2
    \DeclareRobustCommand instead of \newcommand – egreg Feb 09 '23 at 21:30
  • Please edit your query to reproduce some of the error messages you say you're getting. The reason I ask for this is that executing either \subsection{.$\godel{a}$.} or \subsection{.$\godel[thick]{a}$.}(with the macro \godel having been copied from the answer you reference) produces no errors on my system -- MacOS 13.2 "Ventura"; MacTeX2022; pdfTeX Version 3.141592653-2.6-1.40.24; LaTeX2e <2022-11-01> patch level 1; and L3 programming layer <2023-02-07>. Note that I don't find there's a need for \protect. – Mico Feb 09 '23 at 21:33
  • 3
    Incidentally, what makes you think that "Sandy G" is a male? – Mico Feb 09 '23 at 21:36
  • @egreg Unfortunately that did not succeed. – Frode Alfson Bjørdal Feb 09 '23 at 21:51
  • @Sapiens - Please tell us more about your TeX distribution and when you last updated it. – Mico Feb 09 '23 at 22:02
  • @Mico I don't know whether the difference between our programs might make a difference. I use MacOS 11.7.1 Big Sur, and Tex Studio 4.3.1. Another possibility I thought about was whether package conflicts could cause the problem, but it persists even with only – Frode Alfson Bjørdal Feb 09 '23 at 22:04
  • @MicoI In the meantime I did. – Frode Alfson Bjørdal Feb 09 '23 at 22:04
  • TeXstudio is a front end or editor, not a TeX distribution. Do you employ MacTeX? (MacTeX is a TeX distribution.) If so, which vintage, and when did you last update it? – Mico Feb 09 '23 at 22:06
  • I think there may be a package conflict. I am able to avoid the problem with a small subset of the packages I use, and will see if I may reach an understanding of what happens, and resolve the problem. – Frode Alfson Bjørdal Feb 09 '23 at 22:07
  • @Mico How may I see this? Finder was just modified, by the way... – Frode Alfson Bjørdal Feb 09 '23 at 22:10
  • @Sapiens - Check the first line of the log file (in \jobname.log). In my log file, the first line -- which is quite long -- says This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex 2023.2.9) 9 FEB 2023 23:10. MacTeX is TeX Live with some graphical tools. The log file is produced by TeX, not by Finder. – Mico Feb 09 '23 at 22:13
  • @Mico This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex 2022.11.4) 9 FEB 2023 18:57 entering extended mode restricted \write18 enabled. %&-line parsing enabled. – Frode Alfson Bjørdal Feb 09 '23 at 22:19
  • So I'm using Tex Live 2022 – Frode Alfson Bjørdal Feb 09 '23 at 22:20
  • The problem is not caused by a conflict with other packages in the preamble. – Frode Alfson Bjørdal Feb 09 '23 at 22:32
  • The problem is not caused by the preamble, or by using \tableofcontens. – Frode Alfson Bjørdal Feb 09 '23 at 22:55
  • I may have found the problem. \godel{} does not accept mathematical expressions like \exists u(u\in u) as argument. It does, however, accept $\exists u(u\in u)$. – Frode Alfson Bjørdal Feb 10 '23 at 01:00

1 Answers1

1

This works flawlessly:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}

\newcommand{\godel}{}% just to avoid redefining \DeclareRobustCommand{\godel}[1]{% \mspace{1\medmuskip}% \vcenter{\hbox{% \begin{tikzpicture} \nodeinner ysep=-1pt, inner xsep=3pt{$#1\strut$}; \draw[rounded corners=.5mm]([xshift=-1mm]M.north east)--(M.north east)--++(0,-.1); \draw[rounded corners=.5mm]([xshift=1mm]M.north west)--(M.north west)--++(0,-.1); \end{tikzpicture}% }}% \mspace{1\medmuskip}% }

\begin{document}

\tableofcontents

\section{$x\godel{A}y$}

\end{document}

Note that I've changed how to space the construction: using {}\mathbin{...}{} introduces flexible space, that's obviously not wanted: if the formula turns out to need shrinking the space might disappear. Not with \mspace{1\medmuskip}, which is not flexible (and the same amount added by default around a \mathbin).

enter image description here

A better definition:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}

\DeclareRobustCommand{\godel}[1]{% \mspace{1\medmuskip}% \vphantom{#1}% \begin{tikzpicture}[baseline=(M.south)] \nodeinner ysep=0pt,inner xsep=3pt{\smash[b]{$#1\mathstrut$}}; \draw[rounded corners=.5mm]([xshift=-1mm]M.north east)--(M.north east)--++(0,-.1); \draw[rounded corners=.5mm]([xshift=1mm]M.north west)--(M.north west)--++(0,-.1); \end{tikzpicture}% \mspace{1\medmuskip}% }

\begin{document}

\tableofcontents

\section{$x\godel{A}y$}

a $\godel{f}$ b

\end{document}

enter image description here

egreg
  • 1,121,712
  • Many thanks! Unfortunately it does not compile my 50 page document, whereas the solution provided by Sandy G now works, after five hours of editing. The main error I had done was to write, e.g. $\godel{r\in r}$, and not $\godel{$r\in r$}$. I will be interested in using your approach in new documents, from the beginning. – Frode Alfson Bjørdal Feb 10 '23 at 03:10
  • 1
    See https://tex.stackexchange.com/a/674742/4427 for a more refined version of the code – egreg Feb 10 '23 at 18:19