How to right align text and justify it? [Latex] - alignment

I've spent a while trying to figure this out and haven't able to make it so far.
My question is, I have a document in Latex and I would like to change the alignment of a piece of text to the right and justify it too. What I have now can be seen in this picture.
For the image above, this is the code:
I would like to get something like this.
I am just starting out with Latex and I'm still taking some time to learn about it. Thanks in advance.

Actually what you want is:
justified text
in a smaller box shifted to the right of page
The way to do that is with a minipage environment. This allows to determine a box with a given size and to put text (or anything) in it.
Then it is possible to place the minipage at a given position of the page.
Here is an example
\documentclass{article}
\begin{document}
\hfill\begin{minipage}{0.5\linewidth}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{minipage}
\end{document}
and the result
The minipage is 50% of textwidth. Change that value as required.
\hfill does horizontal filling and pushes next element (ie the minipage) towards the right margin. To have a finer control on the position of the minipage, you can use \hspace{6cm}(minipage)\\. It will leave 6cm, insert the minipage box and ends the "line" (\\).

Related

insert image in latex

I tried to insert image in latex. I first uploaded images to sidebar of overleaf. And then I used such code
We still first focus on totally random dataset.\\
\begin{figure}[h]
\centering
\includegraphics[width=0.7\textwidth]{aab.png}
\caption{aab\label{thename}}
\end{figure}
Then we focus on partially random dataset.\\
\begin{figure}[h]
\centering
\includegraphics[width=0.7\textwidth]{abb.png}
\caption{abb\label{thename}}
\end{figure}
At last we look at true dataset.
\begin{figure}[h]
\centering
\includegraphics[width=0.7\textwidth]{aba.png}
\caption{aba\label{thename}} \end{figure}
And then But what I got is
There images are all in wrong positions, they all appear after texts, but they are supposed to be inserted between the texts. Where the issue comes from?
\begin{figure}[h!]instead of \begin{figure}[h] would be the best choice. But you can also use \begin{figure}[H] but you need to add the float package.
Please see:
https://www.overleaf.com/learn/latex/Positioning_images_and_tables, the section under figure environment educates the different parameters and their meaning under figure environment.
The figure environment is meant to float, which means that latex will find a good place for it. You should write your text in such a way that you expect specific positions for the images. Instead you can references them by their number in the text. This method works best if you have a bit more text than in your example, so I added a bit of random text in the example below so you can see how this works.
If you don't want this, you shouldn't use a figure environment. instead you could use the \captionof macro to add captions to your non-figure images.
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\section{The latex way:}
At first, we focus on a totally random dataset, depicted in figure \ref{thenamea}. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.7\textwidth]{example-image-duck}
\caption{aab\label{thenamea}}
\end{figure}
After that we focus on partially random dataset as shown in figure \ref{thenameb}. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.7\textwidth]{example-image-duck}
\caption{abb\label{thenameb}}
\end{figure}
At last we look figure \ref{thenamec} which is the true dataset. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.7\textwidth]{example-image-duck}
\caption{aba\label{thenamec}}
\end{figure}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\clearpage
\section{No floats}
We still first focus on totally random dataset.
{
\centering
\includegraphics[width=0.65\textwidth]{example-image-duck}
\captionof{figure}{aab\label{thenameaa}}
}
Then we focus on partially random dataset.
{
\centering
\includegraphics[width=0.65\textwidth]{example-image-duck}
\captionof{figure}{abb\label{thenamebb}}
}
At last we look at true dataset.
{
\centering
\includegraphics[width=0.65\textwidth]{example-image-duck}
\captionof{figure}{aba\label{thenamecc}}
}
\end{document}

Transcode job failed in google cloud

Unable to trigger transcode jobs
Issue Summary: IAS had some failed transcode jobs for project PROJECT_NUMBER. These were retriggered and roughly ~950/1115 passed but 122 failed.
Project Number: PROJECT_NUMBER
Job ID:
projects/PROJECT_NUMBER/locations/us-west1/jobs/JOB_ID,
Location: us-west1
Job Config See job config:
Source File(s):
I downloaded and analyzed these 3 files, they are all corrupt and have syntax and bitstream errors, they were not captured by the customer properly prior to upload,
please request that they capture them properly and make sure that they can play them back with VLC without issues prior to upload processing
{"type":"log","msg":"av_log(level=ERROR): Concealing bitstream errors\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=64\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=64\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): Concealing bitstream errors\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): Concealing bitstream errors\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=76\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=70\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): Concealing bitstream errors\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=70\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): Concealing bitstream errors\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=64\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=84\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): Concealing bitstream errors\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=64\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=84\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=99\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=64\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=81\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): Concealing bitstream errors\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=65\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): AC EOB marker is absent pos=68\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}
{"type":"log","msg":"av_log(level=ERROR): Concealing bitstream errors\n","line":"init.cc:37","level":"DEBUG","timestamp":"2021-07-22T20:52:33.879Z"}

In TeX, how do I define the label style for compactenum globally?

I have a couple of compactenum elements in my document. I would like define color and type for all labels in a more elegant way than this:
\begin{compactenum}[label=\textcolor{black}{\arabic*.}]
\item lorem
\item ipsum
\item dolor
\end{compactenum}
\begin{compactenum}[label=\textcolor{black}{\arabic*.}]
\item sit
\item amet
\end{compactenum}
How do I set it globally the most elegant way? Is there a way where I can define the behavior for compactenum without using [...] at all?
What you need is \setdefaultenum{\color{black} 1.}{}{}{}. It will set your outer label to be black arabic label. For more information, refer to paralist documentation Here's a MCVE:
\documentclass{article}
\usepackage{paralist,xcolor}
\setdefaultenum{\color{black} 1.}{}{}{}% What you need!
% The 1. is the equivalent of \arabic*.
% The other {}{}{} refer to the list levels,
% i.e. {second level}{third level}{fourth level}
\begin{document}
\begin{compactenum}
\item lorem
\item ipsum
\item dolor
\end{compactenum}
\end{document}

Text exceed from cover page, how to solve it?

I have brought the title, which is a bit long sentence in cover page.
However, it exceeds the page width, how to correct it? Thanks
\vspace{30mm} \centerline{{\bf Title BLAH Blah}}
You could try using the center environment, as it allows natural wrapping at within the text block:
\begin{center}
\bfseries
Lorem ipsum dolor sit amet, consectetur adipiscing elit \ldots
\end{center}
Note the use of \bfseries rather than \bf:
Does it matter if I use \textit or \it, \bfseries or \bf, etc
Will two-letter font style commands (\bf , \it , …) ever be resurrected in LaTeX?

Centering a table wider than the text column

I'm including a table in my LaTeX document and the centering works fine if the table isn't wider than the text column above it, but when the table is wider, the left side of the table sticks to the left side of the text column, and the additional width of the table is on the right side of the page, how can I center the table?
I'd recommend trying the chngpage package.
\documentclass{article}
% allows for temporary adjustment of side margins
\usepackage{chngpage}
% provides filler text
\usepackage{lipsum}
% just makes the table prettier (see \toprule, \bottomrule, etc. commands below)
\usepackage{booktabs}
\begin{document}
\lipsum[1]% just a paragraph of filler text
\medskip% adds some space before the table
\begin{adjustwidth}{-1in}{-1in}% adjust the L and R margins by 1 inch
\begin{tabular}{ll}
\toprule
Sequence & Wide column \\
\midrule
First & Vestibulum porta ultricies felis. In nec mi. \\
Second & Nam vestibulum auctor nibh. In eleifend,
lacus id tristique ullamcorper, mauris urna convallis elit. \\
Third & Ut luctus nisi quam lobortis magna. Aenean sit amet odio
et sapien rutrum lobortis. \\
Fourth & Integer dictum accumsan purus. Nullam erat ligula,
dictum sed, feugiat nec, faucibus id, ipsum. \\
\bottomrule
\end{tabular}
\end{adjustwidth}
\medskip% adds some space after the table
\noindent\lipsum[2]% just a paragraph of filler text
\end{document}
The documentation for the chngpage package is located at the bottom of the chngpage.sty file. I've pulled out the docs for the adjustwidth environment:
Within an adjustwidth environment
the left and right margins can be
adjusted. The environment takes one
optional argument and two required
length arguments:
\begin{adjustwidth}[]{leftmargin}{rightmargin}
A positive length value will increase the relevant margin
(shortening the text lines) while a
negative length value will decrease
the margin (lengthening text lines).
An empty length argument means no
change to the margin. At the end of
the environment the margins revert to
their original values.
For example, to extend the text
into the right margin:
\begin{adjustwidth}{}{-8em}
Any appearance of the optional
argument (even just []) will cause the
values of the margins to switch
between odd and even pages.
If the document is being set
twosided it might be advantageous to
have any wider text extending into the
outside margin. This could be done via
the optional argument, as:
\begin{adjustwidth}[]{}{-8em}
To have the adjusted text
horizontally centered with respect to
any surrounding text, the margins
should be adjusted equally:
\begin{adjustwidth}{-4em}{-4em}
Latex: Centering table larger than textwidth
Usually, you can center tables with \center. But when the table is longer than the \textwidth, it will be align with the left side margin. You can temporarily adjust the textwidth.
% allows for temporary adjustment of side margins
\usepackage{chngpage}
\begin{table}
\begin{adjustwidth}{-.5in}{-.5in}
\begin{center}
\begin{tabular}{|c|}
\hline
And here comes a very long line. And here comes a very long line. And here comes a very long line. \\
\hline
\end{tabular}
\caption{This Table is longer than the text width. And its caption is really long, too. This Table is longer than the text width. And its caption is really long, too. This Table is longer than the text width. And its caption is really long, too. This Table is longer than the text width. }
\label{myTable}
\end{center}
\end{adjustwidth}
\end{table}
If you're using a \table float, the \begin{adjustwidth} ... \end{adjustwidth} has to be contained inside it.
In figures, the figure environment must contain the adjustwidth env.. Furthermore, caption should be left outside of this environment to align with the overall figure's width:
\begin{figure}[h]
\begin{adjustwidth}{-1in}{-1in}% adjust the L and R margins by 1 inch
\centering
\includegraphics[scale=0.44]{res/sth.png}
\end{adjustwidth}
\caption{sth}
\label{fig:sth}
\end{figure}
Are you using a multi-column document? I so, consider the table* variant environment.
In a single column environment your options run to:
Increase the textwidth. But the default margin were choosen for good ergonomic reasons, so this is to be discouraged beyond a minimal tweaking.
Reduce the text size in the table (i.e. \small or even \footnotesize inside the tabular environment). Again, this is less than optimal.
Use the rotating package as suggested in the link Stephan202 gave. I used this for a couple of very large tables in my dissertation (with only the p positioning options) and it came out very nicely.

Resources