0

I would like to align/indent a paragraph such that a specific word or phrase is in the horizontal center of the page, but I have no idea where to start to accomplish it (perhaps by calculating a custom indentation for the first line of the paragraph or using box trickery, but how?). Any suggestions?

Example: example

MWE playground:

\documentclass{article}

\usepackage{blindtext}

\newcommand*\alignword[1]{%
    % do fancy alignment tricks here
    \textbf{#1}%
}

\begin{document}

In this paragraph, the word \alignword{center} should be horizontally centered
on the page, with the rest of the paragraph flowing around it.

Like this (dirty imprecise hack, the amount would be different for each paragraph):

\begingroup
\setlength{\parindent}{3em}
In this paragraph, the word \textbf{center} should be horizontally centered
on the page, with the rest of the paragraph flowing around it.
\endgroup

Likewise in the following paragraph:

\blindtext[1] \alignword{Word} \blindtext[1]

\end{document}
  • Could you please add some background information on the purpose of this special alignment? Also, how shoulud the alignment be achieved? Should there be a bigger indentation of the text if the part before the specific word is too short to fill up the space to the horizontal center? What should happen if the left part of the text is too wide? – leandriis Aug 25 at 16:00
  • I have updated the MWE. I am transcribing a document with a number of short paragraphs that have a name in the center, and I would like the transcription to maintain the alignment of the names in the center of the page. – meide Aug 25 at 16:11
  • This general topic has been the subject of several items in TUGboat, albeit for plain TeX, not LaTeX. But those methods might inspire someone here, so here goes. First, the problem: TeX does windows. Solutions appear in three items in vol. 8, no. 2, starting on page 210. – barbara beeton Aug 25 at 20:27
  • Does this centered word always appear in the first line of the paragraph?? – Steven B. Segletes Aug 25 at 23:13
  • 1
    @StevenB.Segletes no – meide Aug 26 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.