框左對齊

框左對齊

我在我的稿件中使用兩個乳膠結構在文字周圍繪製一個框架,我需要將其左對齊不改變\parindent盒子之前和之後。但兩者都印在 的位置\parindent

在此輸入影像描述

\documentclass[10pt,twoside,toc=listofnumbered,headinclude,footinclude,index=numbered]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[final]{microtype}
\usepackage{blindtext}
\parindent=7mm
\newenvironment{rfbox}{\begin{minipage}{8.0cm}}{\end{minipage}}
\newcommand{\ffbox}[1]{\vspace{0.0cm}{\fbox{\begin{rfbox} #1 \end{rfbox}}}}

\begin{document}

\blindtext\\

\noindent This is left aligned.\\

\fbox{%
\parbox{8cm}{%
\noindent The box around this should be left aligned.

}}\\

\noindent This is also left aligned.\\

\ffbox{
The box around this should also be left aligned.

}\\

\blindtext

\end{document}

答案1

我不確定這個問題,但是 withtcolorbox很容易產生左對齊的框,因為它是預設行為。

\documentclass[10pt,twoside, toc=listofnumbered, headinclude, 
      footinclude, index=numbered]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
%\usepackage[final]{microtype}
\usepackage{blindtext}
\parindent=7mm
%\newenvironment{rfbox}{\begin{minipage}{8.0cm}}{\end{minipage}}
%\newcommand{\ffbox}[1]{\vspace{0.0cm}{\fbox{\begin{rfbox} #1 \end{rfbox}}}}
\usepackage[most]{tcolorbox}

\newtcolorbox{mybox}[1][]{
    sharp corners, colback=white, boxsep=0mm, boxrule=1pt, #1
}

\begin{document}

\blindtext

\noindent This is left aligned.

\begin{mybox}[width=8cm]
This is also left aligned
\end{mybox}

\noindent This is also left aligned.

\begin{mybox}[width=8cm]
The box around this should also be left aligned.
\end{mybox}

\blindtext

\end{document}

在此輸入影像描述

答案2

正如@daleif所說,您可以使用\noindentbefore \fbox,但是該包framed使您的工作更加簡單,並且MWE是:

\usepackage{framed}

\begin{framed}
...
\end{framed}

相關內容