¿Cómo iniciar una nueva línea en \boxed{}?

¿Cómo iniciar una nueva línea en \boxed{}?

Tengo:

\documentclass[12pt,a4paper]{article}
\newcounter{conto}
\setcounter{conto}{\time}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{dsfont}
\usepackage{mathrsfs}
\usepackage{amssymb,amsmath}
\usepackage{cancel}
\begin{document}
\section{Prove}
\(\boxed{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"}\)
\end{document}

pero el resultado es el siguiente:

ingrese la descripción de la imagen aquí

¿Cómo iniciar una nueva línea \boxed{}automáticamente?

Respuesta1

Buenas noches, el \boxedcomando está definido en el amsmath.{sty|dtx}archivo (que es parte del amsmathpaquete), es:

\newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}

Podemos redefinirlo y utilizar matemáticas en línea en su lugar. Con la ayuda del \fboxcomando podemos dibujar un rectángulo, el ancho adecuado es \textwidth-2\fboxrule-2\fboxsep. El núcleo de nuestro trabajo es permitir que las líneas se rompan en los lugares adecuados (comas, comillas) sin perderlas, usemos \allowbreakpara este propósito.

El truco rápido es activar esos caracteres ( \catcodeto 13) y definirlos a nuestro gusto. El único problema en nuestro ejemplo es no entrar en un bucle infinito, por lo tanto almacenamos los caracteres originales antes de la activación en comandos separados.

Generalmente hacemos todo esto en grupo; por ejemplo, usando { }, me salto este paso.

¡Y voilá! Adjunto un pequeño ejemplo. ¡Disfrutar! :-)

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}
% \the\fboxrule % If we wish to see the first used dimension...
% \the\fboxsep  % If we wish to check the second used dimension...
% E.g., we wish to have a nice cozy rectangle across the whole mirror...
\parindent=0pt
% One paragraph typeset for checking purposes only...
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text\par
% Let's compute the real width of the mirror...
\newdimen\temp                % A declaration of a new dimension...
\temp=\textwidth              % The width of the text minus
\advance\temp by -2\fboxrule  %    border from both sides minus
\advance\temp by -2\fboxsep   %    inner separator from both sides.
% Storage of the \boxed command created by the AMS... (amsmath.dtx).
\let\oldboxed=\boxed
% Redefinition of \boxed, let's use breakable inline mathematics...
\def\boxed#1{\fbox{\parbox{\temp}{$#1$}}}
% We'll make comma as an active character according to our wishes...
\def\mycomma{,}
\catcode`\,=13
\def,{\mycomma\allowbreak}
% The same strategy will be applied to one more used character...
\def\mymark{"}
\catcode`\"=13
\def"{\mymark\allowbreak}
% The core of our efforts...
\boxed{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"}\par
% And we are back in reality from our dreams... ;-)
\let\boxed=\oldboxed
\boxed{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"}
\end{document}

ingrese la descripción de la imagen aquí

Solo agregué \pagestyle{empty}el preámbulo del documento para obtener una versión recortada adecuada. Si preferimos una versión no matemática, cámbiela $#1$a just #1en la redefinición del \boxedcomando.

Respuesta2

No estoy seguro si estás haciendo un mal uso del modo matemático; dentro \boxedpuedes usar cualquiera de los amsmathentornos “internos”, en este caso usé aligned:

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}
\[
\boxed{
  \!\begin{aligned}
  &1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,\\
  &a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
  \end{aligned}
}
\]
\end{document}

ingrese la descripción de la imagen aquí

Por favor, sea más preciso si el modo matemático no era lo que tenía en mente.

Respuesta3

También ayuda agregar un espacio en blanco.

\documentclass[12pt,a4paper]{article}
\newcounter{conto}
\setcounter{conto}{\time}
%\usepackage{lmodern}
%\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
%\usepackage{dsfont}
%\usepackage{mathrsfs}
\usepackage{amssymb,amsmath}
%\usepackage{cancel}
\begin{document}
\section{Prove}
\(
\fbox{\parbox{4in}{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"}}
\)
\end{document}

en caja

Debo mencionar que dentro del \parbox ya no estás en modo matemático.

Respuesta4

Puedes usar una pila. Tenga en cuenta que el carácter de fin de línea (EOL) predeterminado es un espacio entre stackengine's \Longstack, lo que funciona bien para su ejemplo. Pero a menudo, si su pila contiene espacios naturales, entonces necesita cambiar el EOL de la pila, lo que hago para la segunda pila, a \\, usando \setstackEOL{}. Además, el uso de \stackMatho \stackTexthará que los argumentos de apilamiento se interpreten como matemáticos o texto, respectivamente, como también muestro.

\documentclass[12pt,a4paper]{article}
\newcounter{conto}
\setcounter{conto}{\time}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{dsfont}
\usepackage{mathrsfs}
\usepackage{amssymb,amsmath}
\usepackage{cancel}
\usepackage{stackengine}

\begin{document}
\section{Prove}
\stackMath
\(\boxed{\Longstack{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
``a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z''}}\)
\section{Prove Again}
\setstackEOL{\\}
\stackText
\(\boxed{\Longstack{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20\\
``a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z''}}\)
\end{document}

ingrese la descripción de la imagen aquí

información relacionada