2

The simplest way to produce Gödel codes is with $\ulcorner$ and $\urcorner$, and we may write $\ulcorner p\urcorner$ to enclose the formula $p$ within codes.

Buss programmed a macro which gives a better appearance than Gödel codes in many contextst.

The macro Godeln{}, which egreg recently suggested, as an aside in an answer to a recent question (Dotted x in mathmode), is an improvement of Buss's improvements of \(\ulcorner \urcorner\).

My question is: May the corners of the egreg codes be rounded, e.g. with TikZ, to obtain codes which are discernibly different?

MWE

\documentclass[]{article}
\usepackage{amsmath, amssymb}

\newlength{\gnCornerHgt} \newlength{\gnArgHgt}

\makeatletter \newcommand{\Godeln}[1]{\mathinner{\mathpalette\Godeln@{#1}}} \newcommand{\Godeln@}[2]{% \begingroup \settoheight{\gnCornerHgt}{$\m@th#1\ulcorner$}% \settoheight{\gnArgHgt}{$\m@th#1#2$}% \ifdim\gnArgHgt<\gnCornerHgt \setlength{\gnArgHgt}{0pt}% \else \addtolength{\gnArgHgt}{-\gnCornerHgt}% \fi \raisebox{\gnArgHgt}{$\m@th#1\ulcorner$}% #2% \raisebox\gnArgHgt{$\m@th#1\urcorner$}% \endgroup } \makeatother

\begin{document}

$\ulcorner 2^2\urcorner$ vs. $\Godeln{2^2}$


\end{document}

Sandy G
  • 42,558
  • 1
    I fear, I don't really understand what you want to achieve, but you cannot simply round the corner of a glyph, in this case the glyphs which the macros \ulcorner and \urcorner output. You cannot transform the path of a glyph, but you can use another glyph or you can create your own "rounded corner" glyphs using TikZ if this is what you want. – Jasper Habicht Feb 08 '23 at 19:24
  • 2
    Having said that, it would be nice if you could clean up your question and make it better readable for others. It is not a good idea in my opinion that your put the question inside your MWE. Question and MWE should be separate parts of the post. – Jasper Habicht Feb 08 '23 at 19:26
  • @JasperHabicht Thanks, I did some more edits, which I think also clarify that the question is on whether "you can create your own "rounded corner" glyphs using Tikz. – Frode Alfson Bjørdal Feb 08 '23 at 22:52
  • Please format your code correctly. I did this for you but you undid my edit. – Sandy G Feb 08 '23 at 22:59
  • @SandyG I did it inadvertently, I believe. – Frode Alfson Bjørdal Feb 08 '23 at 23:10
  • 1
    No problem. I reformatted it. Hope that's ok. – Sandy G Feb 08 '23 at 23:13
  • @SandyG Good. Now my problem is that it does not compile in the presence of all my other packages, as amsmath, amssymb, amsfonts, amsthm, mathtools and others. Are there known conflicts between TikZ and other packages? – Frode Alfson Bjørdal Feb 08 '23 at 23:19
  • @SandyG It compiled! :) I used upper case G and not lower case g as you.

    Thanks again!

    – Frode Alfson Bjørdal Feb 08 '23 at 23:24
  • @SandyG Interestingly, it does not, as its counterparts, compile in section headings. – Frode Alfson Bjørdal Feb 08 '23 at 23:51
  • You need to \protect it in a section heading. I updated my answer with an example. – Sandy G Feb 09 '23 at 01:35

2 Answers2

8

Here is a somewhat simpler draw-it-yourself version with TikZ. You can adjust the radius of the rounded corners by changing the .5mm in the \draw commands. You can adjust the horizontal spacing by changing inner xsep, and the vertical spacing by changing inner ysep.

enter image description here

There is also an optional argument that can be used to change the \draw style. For example, \godel[thick]{a}. Colors work too.

\documentclass{article}

\usepackage{tikz}

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

\begin{document}

Some examples: $\godel{a}\godel{A}\godel{g}\godel{(}$

\section{Here is a G&quot;odel code $\godel[thick]{a}$}

\end{document}

Sandy G
  • 42,558
  • Thanks. With me \section{ $\protect\godel[thick]{A}$} gives many errors so that the document does not compile. The first error is: Argument of \pgfkeys@temp has an extra }. \section{ $\protect\godel[thick]{A}$} – Frode Alfson Bjørdal Feb 09 '23 at 16:25
  • 1
    @Sapiens: I can't reproduce that error. Maybe a typo? If you can't figure it out you could post a new question with a link to this one. – Sandy G Feb 09 '23 at 16:32
  • What gave me problems was: \section{$\protect\godel[thick]{A}$ is ...}. – Frode Alfson Bjørdal Feb 09 '23 at 16:40
  • No, I almost resolved it by using: : \section{~} {\Large \noindent \textbf{19} \indent $\godel{A}$ \textbf{is true just if the end of A is truth}} A drawback is that there is now a lineshift after the Section number. – Frode Alfson Bjørdal Feb 09 '23 at 16:45
  • I posted the following question: https://tex.stackexchange.com/questions/674634/may-we-avoid-the-line-break-after-section-title. – Frode Alfson Bjørdal Feb 09 '23 at 18:23
  • 1
    I am also unable to reproduce any of the errors @Sapiens says he (or she?) is getting. – Mico Feb 09 '23 at 21:38
  • As @egreg suggested, I changed the code to use \DeclareRobustCommand instead of \newcommand. – Sandy G Feb 09 '23 at 23:04
  • Since you have added an optional argument, using \DeclareRobustCommand is not necessary. – egreg Feb 10 '23 at 10:02
  • @SandyG Many thanks for your efforts! I now accepted Greg's answer, as a guidance for those who might be interested in finding the best available answer to the query. But you deserve much recognition as well! – Frode Alfson Bjørdal Feb 10 '23 at 18:31
5

A variant of Sandy G's code. The main differences are

  1. how the baseline is treated, so we're guaranteed that the symbol has the correct one

  2. the argument to \godel is typeset in math mode.

  3. the sidebearings are fixed and don't shrink nor stretch

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

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

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

\begin{document}

\tableofcontents

\section{Egreg's $\godel{A}$ and $\godel[thick]{A}$}

Some examples: $\godel{a}\godel{A}\godel{g}\godel{(}$

Squeezed: \hbox spread -10pt{$\godel{a}\godel{A}$}

Math: $\godel{r\in R}$

\medskip

{\Large Some examples: $\godel{a}\godel{A}\godel{g}\godel{(}$}

\section{Sandy's $\sandygodel{A}$ and $\sandygodel[thick]{A}$}

Some examples: $\sandygodel{a}\sandygodel{A}\sandygodel{g}\sandygodel{(}$

Squeezed: \hbox spread -10pt{$\sandygodel{a}\sandygodel{A}$}

Math: $\sandygodel{$r\in R$}$

\medskip

{\Large Some examples: $\sandygodel{a}\sandygodel{A}\sandygodel{g}\sandygodel{(}$}

\end{document}

enter image description here

egreg
  • 1,121,712
  • Thanks! Does this produce another out pute than your answer to this question: https://tex.stackexchange.com/questions/674695/how-may-i-protect-this-godel-command-for-section-titles/674702#674702 ? – Frode Alfson Bjørdal Feb 10 '23 at 18:00
  • 1
    @Sapiens The version here is more refined. – egreg Feb 10 '23 at 18:08
  • Great! I accept your answer, as a guidance for those who might be interested in finding the best available answer to my query. But Sandy G deserves much recognition as well. – Frode Alfson Bjørdal Feb 10 '23 at 18:18