# TikZ - How can I create a style for nodes which have the shape of a corner?

Probably a silly question, but I currently can't figure out how to create a style definition for a corner. What I want is included in the MWE.

## MWE

\documentclass[
a4paper
]{scrartcl}

\usepackage{
newtxtext,
amsmath,
}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\tikzset{
testtest/.style={
%rectangle, %don't want this
%circle, %don't want this either
draw=gray,
thick
},
}

\listfiles

\begin{document}
Test.
\begin{center}
\begin{tikzpicture}[font=\sffamily\small]
\node[testtest] at (0,0) {Some words.};
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}
\draw[thick] (0,0) -- (2,0) -- (2,0.5) node[below left] {This is what I want. Just a corner. Its size is going to get adapted anyway.};
\end{tikzpicture}
\end{center}
\end{document}


## Picture

-

You can use append after command. Here is your modified MME:

\documentclass[
a4paper
]{scrartcl}

\usepackage{
newtxtext,
amsmath,
}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\tikzset{
testtest/.style={
thick,
append after command={
[thick,shorten >=-0.2bp, shorten <=-0.2bp]
(\tikzlastnode.south east)edge(\tikzlastnode.north east)edge(\tikzlastnode.south west)
}

},
}

\listfiles

\begin{document}
Test.
\begin{center}
\begin{tikzpicture}[font=\sffamily\small]
\node[testtest] at (0,0) {Some words.};
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}
\draw[thick] (0,0) -- (2,0) -- (2,0.5) node[below left] {This is what I want. Just a corner. Its size is going to get adapted anyway.};
\end{tikzpicture}
\end{center}
\end{document}


-

Next code is similar to Tahtisilma's one but with an argument to fix where the corner starts.

\documentclass[tikz,border=3mm]{standalone}

\usepackage{
newtxtext,
amsmath,
}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usetikzlibrary{positioning}

\usepackage{tikz}
\tikzset{
corner/.style={
append after command={%
\pgfextra
\path (\tikzlastnode.south west)--(\tikzlastnode.south east) coordinate [pos=#1] (aux);
\draw[gray,thick] (aux)-|(\tikzlastnode.north east);
\endpgfextra
}
},
}

\begin{document}
\begin{tikzpicture}
\node[corner=.25] (A) {This is what I want. Just a corner. Its size is going to get adapted anyway.};
\node[corner=.5, below=of A] (B) {This is what I want. Just a corner. Its size is going to get adapted anyway.};
\node[corner=.60, below=of B] (C) {This is what I want. Just a corner. Its size is going to get adapted anyway.};
\end{tikzpicture}
\end{document}


If you don't want a corner inside TikZ but within some regular text tcolorbox is another possibility:

\documentclass{article}

\usepackage{
newtxtext,
amsmath,
lipsum
}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[skins]{tcolorbox}

\newtcbox{\mycorner}[1][.5]{enhanced,nobeforeafter,
tcbox raise base,
arc=0pt, outer arc=0pt, opacityback=0, opacityframe=0,
boxsep=0pt, left=0pt, right=0pt, top=0pt, bottom=0pt,
overlay = {\path (frame.south west)--(frame.south east) coordinate[pos=#1] (mycorneraux); \draw (mycorneraux)-|(frame.north east);}
}

\begin{document}

This is what I want. Just a corner. \mycorner{Its size is going to get adapted anyway.}

This is what I want. Just a corner. Its size is going \mycorner[.6]{to get adapted anyway.}

This is what I want. Just a corner. Its size is going to get adapted \mycorner[.8]{anyway.}

\end{document}


-