TransWikia.com

equations overrun tcolorbox

TeX - LaTeX Asked by mkk on November 28, 2020

The following works, but the equation spills over outside the box, is there a way to make the box bigger?

Edit:
After making the MWE I realize that this is clearly a margins issue, so I’m not sure the original question is valid…

MWE:

Compile the following with pdflatex --shell-escape test.tex

documentclass{article}
% formatting
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{minted}
usepackage[most]{tcolorbox}


% figures
usepackage{graphicx}
graphicspath{ {./figs/} }
usepackage{caption}
usepackage{subcaption}

% tables
usepackage{pgfplotstable}
usepackage[shortlabels]{enumitem}

% date
usepackage[mmddyyyy]{datetime}

% set the styling for python code
setminted[python]{frame=lines,framesep=2mm,bgcolor=black!10,fontsize=footnotesize,linenos}

begin{document}

section*{new}
Lorem ipsum dolor sit amet, nec ex tation diceret suscipit, et quo quidam sententiae. Ut nam accusam persequeris, in cum harum ridens prodesset. Ut has melius voluptua principes, ne altera suscipiantur eum, vis autem simul omnes te. Alia posse abhorreant id mea, has vide iusto argumentum te, per pertinax erroribus ad. Probo definiebas referrentur has in. Enim adolescens ne nam, alii dissentiet ad qui, eam id dico moderatius.
Nihil persius repudiandae has at, an aliquid apeirian concludaturque sed. An facer ancillae mei. Eam ridens euripidis ex, ius ignota perpetua vulputate in. Vel an cibo quaestio, saepe tempor oportere ea sea, eu sea elit fabulas quaestio. Per solet tantas no.
Pri brute reprehendunt id, id soleat senserit repudiandae eum. Cu eum utroque molestiae. Purto illum malis ad pro. Saepe noluisse elaboraret eu sit. An vel verear antiopam, sale scriptorem suscipiantur ex has, est utamur accusamus signiferumque id. Postea efficiendi appellantur an usu, facer dignissim ius id.
Nec ridens delicata an, agam dissentias temporibus te nec, usu autem aperiam et. Mutat neglegentur vim eu. Ei ius mazim liber dissentiunt, an mea partem viderer moderatius, vim tantas nullam postea eu. An sint graeco disputando pro, possim aliquam definitiones et has.
Justo volutpat nam et. Eam ne elitr dolorem iracundia, id vero erroribus intellegat eum. Tacimates philosophia ad mei, sit nihil possit molestie ne, duo prima recusabo an. Veri impetus in est.
begin{tcolorbox}[colback=yellow!10!white,colframe=black]
  textit{blah.}
  tcblower
  begin{align*}
    frac{partial J_j}{partial theta_i} J_j(theta_i) &= 
              -frac{y^{j}}{sigma(x^{(j)}theta^T)} frac{partial}{partial theta_i}sigma(z)
              -frac{1-y^{j}}{1-sigma(x^{(j)}theta^T)} frac{partial}{partial theta_i}1-sigma(z)
              text{hspace{2em}comment comment comment}[0.5em]
  end{align*}
end{tcolorbox}


end{document}

MWE Output:
enter image description here

One Answer

By default, displayed equations cannot auto break. Packages breqn and nath both introduce some sort of auto breaking and alignment for displayed equations.

In your case, perhaps using tag*{comment comment comment} in place of text{hspace{2em}comment comment comment} is enough.

documentclass{article}
% formatting
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{minted}
usepackage[most]{tcolorbox}


% figures
usepackage{graphicx}
graphicspath{ {./figs/} }
usepackage{caption}
usepackage{subcaption}

% tables
usepackage{pgfplotstable}
usepackage[shortlabels]{enumitem}

% date
%usepackage[mmddyyyy]{datetime}

% set the styling for python code
setminted[python]{frame=lines,framesep=2mm,bgcolor=black!10,fontsize=footnotesize,linenos}

begin{document}

section*{new}
Lorem ipsum dolor sit amet, nec ex tation diceret suscipit, et quo quidam sententiae. Ut nam accusam persequeris, in cum harum ridens prodesset. Ut has melius voluptua principes, ne altera suscipiantur eum, vis autem simul omnes te. Alia posse abhorreant id mea, has vide iusto argumentum te, per pertinax erroribus ad. Probo definiebas referrentur has in. Enim adolescens ne nam, alii dissentiet ad qui, eam id dico moderatius.
Nihil persius repudiandae has at, an aliquid apeirian concludaturque sed. An facer ancillae mei. Eam ridens euripidis ex, ius ignota perpetua vulputate in. Vel an cibo quaestio, saepe tempor oportere ea sea, eu sea elit fabulas quaestio. Per solet tantas no.
Pri brute reprehendunt id, id soleat senserit repudiandae eum. Cu eum utroque molestiae. Purto illum malis ad pro. Saepe noluisse elaboraret eu sit. An vel verear antiopam, sale scriptorem suscipiantur ex has, est utamur accusamus signiferumque id. Postea efficiendi appellantur an usu, facer dignissim ius id.
Nec ridens delicata an, agam dissentias temporibus te nec, usu autem aperiam et. Mutat neglegentur vim eu. Ei ius mazim liber dissentiunt, an mea partem viderer moderatius, vim tantas nullam postea eu. An sint graeco disputando pro, possim aliquam definitiones et has.
Justo volutpat nam et. Eam ne elitr dolorem iracundia, id vero erroribus intellegat eum. Tacimates philosophia ad mei, sit nihil possit molestie ne, duo prima recusabo an. Veri impetus in est.
begin{tcolorbox}[colback=yellow!10!white,colframe=black]
  textit{blah.}
  tcblower
  begin{align*}
    frac{partial J_j}{partial theta_i} J_j(theta_i) &= 
              -frac{y^{j}}{sigma(x^{(j)}theta^T)} frac{partial}{partial theta_i}sigma(z)
              -frac{1-y^{j}}{1-sigma(x^{(j)}theta^T)} frac{partial}{partial theta_i}1-sigma(z)
              tag*{comment comment comment}
  end{align*}
end{tcolorbox}


end{document}

enter image description here

Correct answer by muzimuzhi Z on November 28, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP