# Customizing contour labels in ContourPlot

I have a contour plot. I want to make some changes in the contour labels. I want them to place along each contour in white color. Here is my code

ClearAll["Global*"];
f[x_, y_] := x + y^-1;
p = ContourPlot[
f[x, y], {x, -5, 5}, {y, -5, 5},
Contours -> 10,
ContourLabels -> True,
LabelStyle -> {Directive[Bold, Medium], White,
RotateLabel -> True},
ImageSize -> Large
]


The output of this code is

but I want something like this

How can I figure it out? Many thanks.

You can use a pure function with a Text object as the ContourLabels option setting. The fourth argument of Text specifies the direction, which can be computed with:

f[x_, y_] := x + y^-1
t[x_, y_] = Grad[f[x, y], {x, y}] . {{0, -1}, {1, 0}};


Then:

ContourPlot[
f[x, y],
{x,-5,5},
{y,-5,5},
Contours->10,
ContourLabels->Function[{x,y,z},Text[z,{x,y},{0,0},t[x,y], BaseStyle->FontColor->White]]
]
`