2

I'm trying to shade the area between the 2 bold lines in the middle of the graph. This is my progress until now:

\documentclass[10pt,a4paper]{article}
\usepackage[spanish]{babel}
\usepackage[margin=1.27cm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm, bm}
\usepackage{pgfplots}
\usepackage{float}
\usepackage{multicol}
\usepackage{bigints}
\usepackage{fullpage}
\usepackage{tikz}
\usepackage{caption}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{subcaption}


\begin{document}

\begin{figure}[H]
\centering
\caption*{Bounds for a Call option}
\par
\begin{tikzpicture}
\draw[thick] (0,4) node[left=2pt] {$C_t$} -- (0,0) ;
\draw[thick] (0,0) node[left=2pt] {0} -- (4,0) node[below=2pt] {$S_t$} node[right=2pt] {};
\draw[thick] (0,0) node[left=2pt] {0} -- (2,0) node[below=2pt] {$\frac{X}{R_f}$} node[right=2pt] {};
\draw[line width=1mm] (0,0) -- (2,0);
\draw[line width=1mm] (2,0) -- (4,4);
\draw[line width=1mm] (0,0) -- (2,4);
\draw(2,2) node{$C_t$} ;
\end{tikzpicture}
\end{figure}

\end{document}

Thank you!

Lucas
  • 23

1 Answers1

3

You only need to combine the three thick lines to one path, and add the key fill=<color>. This has the additional benefit that the line joins look good. (This is also true for the axes. Overall you only need two paths.)

\documentclass[10pt,a4paper]{article}
\usepackage[spanish]{babel}
\usepackage[margin=1.27cm]{geometry}
\usepackage{tikz}

\begin{document}

\begin{figure}[htb]
\centering
\caption*{Bounds for a Call option}
\par
\begin{tikzpicture}
\draw[thick] (0,4) node[left=2pt] {$C_t$} -- (0,0) 
 node[left=2pt] {0} -- node[below=2pt] {$\frac{X}{R_f}$} (4,0) node[below=2pt] {$S_t$};
\draw[line width=1mm,fill=gray!42] (2,4) -- (0,0) -- (2,0) -- (4,4)
 (2,2) node{$C_t$} ;
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

You may also change the line joins, let me shamelessly advertize this very recent post for getting an idea. ;-) E.g.

  \draw[line width=1mm,fill=gray!42,line join=round,line cap=round] (2,4) -- (0,0) -- (2,0) -- (4,4) (2,2) node{$C_t$} ;

gives you

enter image description here

As you can see, I removed quite a few packages (but kept babel because it may cause interference and I wanted to be sure it does not).