automatically adjust the size of a minipage - latex

I'm trying to get a way to automatically adjust the size of a minipage.
I am creating a report which will have several "paragraphs" that have a floating image on the left and some text on the right of that image and eventually below it if there is enough text. The both of them ( image + text ) make together a "semantic block".
First I did that :
\begin{wrapfigure}{L}{0.15\textwidth}
\centering
\includegraphics[width=0.1\textwidth]{image}\\
\emph{image caption with no "figure1"}
\end{wrapfigure}
Text related to this image\\
Text related to this image\\
Text not related to this image\\
and of course the text not related to the image was considered like the other lines of text, printing on the right of the image.
So i tried to wrap it all :
\begin{minipage}[c][10cm]{20cm}
\begin{wrapfigure}{L}{0.15\textwidth}
\centering
\includegraphics[width=0.1\textwidth]{image}\\
\emph{image caption with no "figure1"}
\end{wrapfigure}
Text related to this image\\
Text related to this image\\
\end{minipage}
Text not related to this image\\
but it really isn't convenient and the height is fixed.
If there is a better way to do it not using minipage that would be great too.
In the end i plan to make it into a \newenvironment taking 2 parameters : image name and text so I can use it easily in the article.
EDIT: fixed a typo in 2nd code

Related

How to align a picture correctly in Overleaf

I want to insert an image on my text but the image always aligns on top of the text and not below as I wanted to. Does anyone know how to accomplish this?
This is the image I want to display on the bottom
\subsection{DistribuciĆ³n Normal}
all that text in spanish
\begin{figure}
\centering
\centerline{\includegraphics[width=8cm,height=8cm]{fdd.eps}}
\end{figure}
If you want to specify where the figure has to be, you have to use some options of the figure environment: for example
all that text in spanish
\begin{figure}[h]
\centering
\includegraphics[width=8cm,height=8cm]{fdd.eps}
\end{figure}
means that LaTeX will try to put the figure where you inserted the figure environment ([h]ere). Other options include
t: top
b: bottom
p: on a special page only for floating environments
You can use several options, for example
all that text in spanish
\begin{figure}[htb]
\centering
\includegraphics[width=8cm,height=8cm]{fdd.eps}
\end{figure}
LaTeX will try to put the figure following the order of the options provided: first it will try to put it [h]ere, then on the [t]op and finally, if the other two possibilities are not available, it will put the figure on the [b]ottom of the page. This strategy lets LaTeX decide the best position for the figure.
For references, see this Overleaf document.

Latex table formatting: rotate, fit in page, caption

I am trying to format a table in latex. I am facing following problems:
There are space on the left side of the table, but my table is not using that space rather it floated to right side and moving out of the page.
To rotate I used \rotatebox, after using this I can not use caption for the table. I get error if I use caption.
If my text in a cell is bigger then it goes out of the cell. I can not keep it in a fixed width.
There are no borders in last two cells.
How can I fix all these things? I have been looking around but if I make something work then others don't work. Could not manage a perfect solution for this. Please give me a workable solution for this.
Below is my sample code
\begin{table*}
\centering
\rotatebox{90}{
%\caption{This is a test caption}
\label{tab:the_table}
\begin{tabular*}{\textwidth}{|c|c|c|c|c|c|c|c|c|c|}
\hline
Column1 &Column2 &Column13 Design &Column4 &Column5 &Column6 &Column7 &another test Column &Last test column \\\hline
First Content &more test content &more test content &more test content &more test content &more test content &more test content &more test content &more test content \\\hline
\end{tabular*}
}
\end{table*}
I assume this question is related to your other one where you have used the IEEEtran document class.
Q1: There are space on the left side of the table, but my table is not using that space rather it floated to right side and moving out of the page.
The \centering only works, if there is enough space within the line. This is only an issue, if the table is not rotated. With rotation, the examples works fine (see below). However, the publisher does not allow to place text within the page margins.
Q2: To rotate I used \rotatebox, after using this I can not use caption for the table. I get error if I use caption.
I have answered this here, for you other question.
Q3: If my text in a cell is bigger then it goes out of the cell. I can not keep it in a fixed width.
Q4: There are no borders in last two cells.
This can be fixed, if you use the environment tabular instead of tabular*. Please note, that tabular does not a take width parameter. The tabular width is calculated from the content only.

LateX: Equation Like "box" for a block of text

Hi I'm using LateX. I have a block of text that I'd like to have a small box like space highlighting the are (just like a \begin{equation} but for text).
Is there such a thing in LateX?
I'm not 100% sure what you're asking I'm afraid, but if you just want to indent text with a margin on each side of the page to make it stand out, you can use...
\begin{quotation}
Quotation is good for long blocks of text that you want highlighted
\end{quotation}
\begin{quote}
Quote is suited to a single block of quoted text.
\end{quote}
If you actually want to have a physical black box around the text, you might want to consider wrapping it in a tabular / table, or you might want to delve into minipages and/or par box environments...
Is \makebox what you're looking for?
To create boxes of text that behave differently from the rest of the text, we can use
\makebox[width][pos]{text}
The width sets the width the of the box. The pos sets the positioning of the text - either r (right justified text), l (left justified), or s (stretched to fill the box). If the pos parameter is left out, as in \makebox[1in]{centerme}, the text is centered. The text is placed in the box. If you want to draw a box around the text, use \framebox just as you would use \makebox.
\mbox{text} and \fbox{text} are quick versions of \makebox and \framebox, which create a box to fit the size of the text.
There are some more examples at http://www.artofproblemsolving.com/wiki/index.php?title=LaTeX:Layout#Boxes

Variable font height via tables in LaTeX

I've been looking for a more elegant solution to the following typesetting problem. Consider those banners found in print media where the text is aligned like:
B I G T E X T
small text small text small text
m o r e m e d i u m t e x t
The font sizes are adjusted so that the height is scaled down for longer lines of text such that each line has equal width. I've written a small script that runs each line separately, compiles, crops the resulting pdf and then \includegraphics each in a table. This gives the desired effect but requires an both an outside script and pdfcrop (which only crops to a white bounding box). Since much of LaTeX is self-aware, I imagine it would be possible to have it recognize the width of a box and scale it appropriately so that any text fits exactly into the desired width.
Any thoughts or ideas on how a pure LaTeX implementation might work?
EDIT As a supplement to the suggested solution by AVB (since large code in comments looks awful), I've posted below the code used so that others may find it easily.
\documentclass[]{article}
\usepackage[pdftex]{graphicx}
\begin{document}
\begin{table}[l]
\resizebox{10cm}{!}{BIG Text} \\
\resizebox{10cm}{!}{small text small text small text} \\
\resizebox{10cm}{!}{Medium Text Medium Text}
\end{table} \end{document}
First, read the TeX FAQ entry titled Changing the space between letters. Depending on your circumstances, the packages and recommendation in that FAQ may suffice.
Also, take a look at the \scalebox and \resizebox commands in the graphicx package. They do what the names imply.
I'm sure that this could be improved upon, and due to different font implementations at different sizes then it isn't going to be exact, but here's a quick-and-dirty way to do it:
\documentclass[10pt]{article}
\usepackage{pgfmath}
\usepackage{anyfontsize}
\newlength{\mywidth}
\newlength{\testwidth}
\setlength{\mywidth}{4in}
\newcommand{\fixedwidth}[1]{%
\settowidth{\testwidth}{#1}%
\pgfmathsetmacro{\x}{round(\mywidth/\testwidth * 10)}%
\pgfmathsetmacro{\y}{round(\mywidth/\testwidth * 15)}%
\bgroup\fontsize{\x pt}{\y pt}\selectfont#1\egroup}
\begin{document}
\fixedwidth{hello world}
\fixedwidth{greetings earthlings}
\end{document}
In practice, it's a little less than the 4in, but the two lines of text do get scaled to the same amount.
Check out the package textfit. Usage:
\scaletowidth{width}{text}
or
\scaletoheight{height}{text}

Presentation with latex, changing the width in each frame

In my presentation, I use \usetheme{Warsaw} and in order to increase the usable space in each frame, I use \useoutertheme{infolines}. In this way, the bar at the bottom of each page is equally divided between author's name, title, and date and slide number. Is there anyway to change the width of each section? For example, I need more space for the title compared to author's name or date. Any comment is highly appreciated. Also, the code I am using is the following:
\usepackage{beamerthemesplit}
\usetheme{Warsaw}
\useoutertheme{infolines}
\title[...]{...}
\author[...]{...}
\institute{...}
\date{...}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
Thank you.
Find the beamerouterthemeinfolines.sty file (in the ...\latex\beamer\themes\outer folder). You will see that the 1:1:1 width is hard-coded using wd=.333333\paperwidth for each box, so you will have to edit the style file.
The following is not tested, but should set you on the right path.
Change those values as you want, then save the file under a different name, say beamerouterthemeunevenlines.sty. Now use unevenlines as your outer theme.

Resources