I have created 3 tcolorbox, one left, one right and one down. The idea is for the text to be at the left of the graph, at the right and below of the graphs ( I included the graphs so it can be better explained.
The problem I can't fix is the alignment. I want the text justified in the 3 cases (keft, right and down), but all I get is flush left text.
I hope this makes sense, thanks!
Here is the code:
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{hyperref}
\usepackage{lipsum}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{babel}
\usetikzlibrary{arrows.meta,automata, decorations.pathreplacing}
\usepackage[most]{tcolorbox}
\usepackage{amsthm,amssymb,amsfonts}
\usepackage{tikz,lipsum,lmodern}
\usepackage{tabularx}
\usepackage{qrcode}
\usepackage{parskip}
\geometry{letterpaper, portrait, margin=1.3in}
% esto es para las cajas con los gráficos
\newtcolorbox[blend into=figures]{myfigureright}[2][]{%
float=htb!,blend before title=colon hang,colback=yellow!5!white,colframe=yellow!50!black,colbacktitle=yellow!75!black,title={#2},every float=\centering,halign=flush center,halign lower= left,sidebyside align=top seam,lower separated=false,sidebyside,righthand ratio=0.4, valign lower=top
#1}
\newtcolorbox[blend into=figures]{myfiguredown}[2][]{%
float=htb!,blend before title=colon hang,colback=yellow!5!white,colframe=yellow!50!black,colbacktitle=yellow!75!black,title={#2},halign=flush center,halign lower= left,lower separated=false, valign lower=top,
#1}
\newtcolorbox[blend into=figures]{myfigureleft}[2][]{%
float=htb!,blend before title=colon hang,colback=yellow!5!white,colframe=yellow!50!black,colbacktitle=yellow!75!black,title={#2},halign lower=center,halign=left,sidebyside align=top seam,lower separated=false,sidebyside,righthand ratio=0.666,
#1}
\title{book 1}
\author{jmv }
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\chapter{graficos con texto abajo, izq, der}
\newpage
\begin{myfigureright}{RIGHT}
\begin{tikzpicture}[scale=0.04]
%titulo
\node [above] at (60,120) {$\textrm{Mercado de los lápices}$};
%ejes
\draw[very thick,<->] (0,120) node[above left]{$P$}--(0,0)--(150,0) node[below right]{$Q$};
%Curvas
\draw(0,100)--(100,0) node [right] at (90,10) {$Dda$};
\draw(20,0)--(120,100) node[right]{$Of$};
\end{tikzpicture}
\tcblower
Solución al equilibrio de mercado en el mercado de los lápices, representado por:
\begin{align*}
Q^D&=100-P\\
Q^O&=20+P
\end{align*}
\lipsum[1]
\end{myfigureright}
\begin{myfiguredown}{DOWN}
\begin{tikzpicture}[scale=0.04]
%titulo
\node [above] at (60,120) {$\textrm{Mercado de los lápices}$};
%ejes
\draw[very thick,<->] (0,120) node[above left]{$P$}--(0,0)--(150,0) node[below right]{$Q$};
%Curvas
\draw(0,100)--(100,0) node [right] at (90,10) {$Dda$};
\draw(20,0)--(120,100) node[right]{$Of$};
\end{tikzpicture}
\tcblower
Solución al equilibrio de mercado en el mercado de los lápices, representado por:
\begin{align*}
Q^D&=100-P\\
Q^O&=20+P
\end{align*}
\lipsum[1]
\end{myfiguredown}
\begin{myfigureleft}{LEFT}
Solución al equilibrio de mercado en el mercado de los lápices, representado por:
\begin{align*}
Q^D&=100-P\\
Q^O&=20+P
\end{align*}
\lipsum[1]
\tcblower
\begin{tikzpicture}[scale=0.04]
%titulo
\node [above] at (60,120) {$\textrm{Mercado de los lápices}$};
%ejes
\draw[very thick,<->] (0,120) node[above left]{$P$}--(0,0)--(150,0) node[below right]{$Q$};
%Curvas
\draw(0,100)--(100,0) node [right] at (90,10) {$Dda$};
\draw(20,0)--(120,100) node[right]{$Of$};
\end{tikzpicture}
\end{myfigureleft}
\end{document}
\justify{\lipsum[1]}
with\usepackage{ragged2e}
works to justify\justify
command is like\center
and does not take an argument, so the form you show would apply to the rest of the document or environment and it is the internal form of thejustify
environment. the command form (when it is used) is\justifying
which has the same syntax as\centering
which again does not take an argument.every float=\centering
which puts\centering
at the start. You could use ragged2e's\justifying
to set it back but I think it is clearer if you avoid setting that in the tcolorbox option and explicitly center the parts you want to center by using\begin{center} \end{center}
around them.