Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6832829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:54:22+00:00 2026-05-26T22:54:22+00:00

Suppose I want a string, say 123, to fill a given rectangle, like so:

  • 0

Suppose I want a string, say “123”, to fill a given rectangle, like so:

Show[Plot[x, {x, 0, 1}], 
     Graphics[{EdgeForm[Thick], Yellow, Rectangle[{.1, .5}, {.4, .9}]}], 
     Graphics[Text[Style["123", Red, Bold, 67], {.1, .5}, {-1, -1}]]]

a string in a rectangle

But I hand-tuned the font size there (67) so that it would fill up the rectangle.
How would you make an arbitrary string fill up an arbitrary rectangle?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:54:23+00:00Added an answer on May 26, 2026 at 10:54 pm

    I believe that this is a known difficult problem. The best answer I could find is from John Fultz.

    TextRect[text_, {{left_, bottom_}, {right_, top_}}] := 
     Inset[
      Pane[text, {Scaled[1], Scaled[1]},
       ImageSizeAction -> "ResizeToFit", Alignment -> Center],
      {left, bottom}, {Left, Bottom}, {right - left, top - bottom}]
    
    Show[
     Plot[x, {x, 0, 1}],
     Graphics[{
       {EdgeForm[Thick], Yellow, Rectangle[{.1, .5}, {.4, .9}]},
       TextRect[Style["123", Red, Bold], {{.1, .5}, {.4, .9}}]
     }]
    ]
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In perl suppose I have a string like 'hello\tworld\n' , and what I want
Suppose I want to match abc within the string s only if it occurs
Ok, suppose I want to store the address 0xcdddd298 in a C string so
Suppose I have a string 04032010. I want it to be 04/03/2010. How would
Suppose I have a string 'johndoe@hotmail.com' . I want to store the string before
suppose I have this string: some striinnngggg <a href=something/some_number>linkk</a> soooo <a href=someotherthing/not_number>asdfsadf</a> I want
I have a table with four columns, say P_Key(int), Ref_Key(int), Key(String), Value(Integer). I want
I am having a string and want to get some part of it. Suppose
Suppose I have a String , say one two three one one two one
Suppose I have the memory address as a string representation (say 0x27cd10). How can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.