0

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}
6
  • \justify{\lipsum[1]} with \usepackage{ragged2e} works to justify
    – js bibra
    Jan 8 '20 at 13:27
  • 2
    @jsbibra justification is the default so you almost never need to specify it, and the package \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 the justify environment. the command form (when it is used) is \justifying which has the same syntax as \centering which again does not take an argument. Jan 8 '20 at 13:32
  • @DavidCarlisle So I am doing something in my code that is breaking the justification by default? Thanks
    – jmvicuna
    Jan 8 '20 at 14:01
  • 1
    @jmvicuna yes you are using 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. Jan 8 '20 at 14:18
  • unrelated but I wouldn't use float=htb! not including p makes it more likely to go to the end, and including ! which means "ignore the default settings, just for this float" is a slightly inconsistent thing to have as a default Jan 8 '20 at 14:19
1

I found what the problem was, I was using

halign=left,

And that was the cause of the problem. As suggested by @David Carlisle, the justified was the default setting, so I was overriding it with this command.

Thanks for the time.

0

Adding \justify{\lipsum[1]} with \usepackage{ragged2e} works to justify

enter image description here

\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}
\usepackage{ragged2e}

\geometry{letterpaper, portrait, margin=1.3in} 
\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}
\begin{document}

\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*}
\justify{\lipsum[1]}
\end{myfiguredown}


\end{document}
1
  • 2
    as I commented above \justify{...} is incorrect syntax. Jan 8 '20 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.