2

How to draw such a box in Latex? According to google, I tried the below method. When multi-line text appears, the text cannot be displayed left-aligned. And the distance between the text and the upper and lower borders is also very large.

Is there any way? Thanks! ! !

\fbox{%
    \parbox{0.42\textwidth}{%
        \begin{center}
        \raggedleft
          This is a test.
        \end{center}
    }%
}

enter image description here

Gerrie
  • 271
  • Welcome to TeX.SE... – MadyYuvi Jan 13 '23 at 04:45
  • 1
    \raggedleft means right-aligned. Get rid of it. And center does what it says. Left aligned is the default in a \parbox. – barbara beeton Jan 13 '23 at 04:50
  • 1
    @Gerrie: Can you provide the community with a better title to your question? Asking "How can I get [this]?" doesn't anyone. – Werner Jan 13 '23 at 05:31
  • Just in case you don't have it: This Wikibook on Latex can replace a google search many times:https://en.wikibooks.org/wiki/LaTeX . Also, use this sites search capabilities, which also inludes the "Related" links to the right. – MS-SPO Jan 13 '23 at 08:50
  • center also adds space above and below. In this case, it is used purely to add extra space (see also \fboxsep). The trivlist environment would have been simpler. Does google actually provide LaTeX help or just point you to bad (but popular) advice? – John Kormylo Jan 13 '23 at 16:57

1 Answers1

4

Easy thing is:

\usepackage{framed}
\begin{document}

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

MadyYuvi
  • 13,693