\boxed{} で新しい行を開始するにはどうすればよいでしょうか?

\boxed{} で新しい行を開始するにはどうすればよいでしょうか?

私は持っている:

\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}

ただし、出力は次のようになります。

ここに画像の説明を入力してください

自動的に新しい行を開始するにはどうすればよいでしょうか\boxed{}?

答え1

こんばんは、コマンドはファイル(バンドルの一部)\boxedで定義されています。次のとおりです。 amsmath.{sty|dtx}amsmath

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

これを再定義して、代わりにインライン数学を使用することができます。 コマンドの助けを借りて\fbox、長方形を描くことができます。適切な幅は です\textwidth-2\fboxrule-2\fboxsep。私たちの仕事の核心は、行を失うことなく適切な場所 (カンマ、引用符) で改行できるようにすることです。この目的のために を使用しましょう\allowbreak

手っ取り早い方法は、これらの文字をアクティブにして (\catcodeから13)、必要に応じて定義することです。この例の唯一の問題は、無限ループに陥らないようにすることです。そのため、アクティブ化する前の元の文字を別のコマンドに保存します。

通常、これをすべてグループで実行します (例: )。{ }この手順は省略します。

では、どうぞ!小さな例を同封します。お楽しみください! :-)

\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}

ここに画像の説明を入力してください

\pagestyle{empty}適切に切り取られたバージョンを取得するために、ドキュメントの序文にのみ追加しました。数学的でないバージョンが望ましい場合は、コマンドの再定義のみ$#1$に変更してください。#1\boxed

答え2

数式モードを誤って使用しているかどうかはわかりませんが、その中では任意\boxedの「内部」amsmath環境を使用できます。この場合は、以下を使用しました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}

ここに画像の説明を入力してください

数式モードが想定していなかった場合は、より正確に記述してください。

答え3

空白を追加するのも役立ちます。

\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}

箱入り

\parbox 内では、もはや数式モードではないことに注意する必要があります。

答え4

スタックを使用できます。 のデフォルトの行末 (EOL) 文字はスペースであり、この例では問題なく機能することに注意してくださいstackengine\Longstackただし、スタックに自然スペースが含まれている場合は、スタックの EOL を に変更する必要があります。2 番目のスタックでは、 を\\使用してに変更しています。また、または を\setstackEOL{}使用すると、スタック引数がそれぞれ数式またはテキストとして解釈されます。これも示しています。\stackMath\stackText

\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}

ここに画像の説明を入力してください

関連情報