새로운 답변

새로운 답변

문장을 가운데 정렬(왼쪽 정렬 및 오른쪽 정렬)하고 싶습니다.이내에한 단락은 Word에서 [newline] + [center this line] + [newline]. 그러나 LaTeX에서는 centering명령이 전체 단락에 영향을 미치며 그룹에만 영향을 미치려면 \par해당 그룹의 시작과 끝에 가 필요합니다. 동시에 center환경은 추가적인 수직 공간을 추가합니다. 내 필요에 맞는 명령이 있다는 것을 알고 있지만 centerline"왼쪽 정렬" 또는 "오른쪽 정렬"과 관련하여 대응되는 명령이 없는 것 같습니다. MWE는 다음과 같습니다.

\documentclass{article}

\begin{document}
I want to center\\
"This piece of text"\\
within this paragraph.

I don't want to break the
{\par\centering paragraph like\par}
this.

How to achieve the effect\\
\centerline{without \texttt{centerline}}\\
or \begin{center}
the \texttt{center} environment?
\end{center}
\end{document}

여기에 이미지 설명을 입력하세요

답변1

새로운 답변

가 지적한 바와 같이@캄파\leftline실제로 LaTeX에 이미 포함되어 있고 및 호출되므로 자신만의 대응 항목을 정의할 필요가 없습니다 \rightline. 그래서 당신은 사용할 수 있습니다

\documentclass[]{article}

\begin{document}
\hsize=5cm % just so that line breaks are a bit earlier
This is some longish text that is long and needs me to centre some
material\\
\centerline{here is center}
Also I'd like to display some stuff to the left\\
\leftline{here is left}
and to put something on the right\\
\rightline{here is right.}
\end{document}

이전 답변

후손을 위해 보관됩니다.

왼쪽 및 오른쪽 정렬에 대한 대응 항목을 정의하여 얻을 수 있습니다. 다음을 수행해야 합니다. 한 줄보다 넓지 않은 내용만 의도한 대로 작동하며 내부에서는 \@@line자동 줄 바꿈이 발생하지 않습니다.

궁금한 점이 있으시면 \hss접착제가 무엇입니까?시간동양적으로에스트렌치 또는에스채워지는 지정된 공간에 필요한 만큼 축소됩니다( 현재 너비만큼 넓어야 하는 \@@line단일이므로 텍스트 너비입니다).\hbox\hsize

\documentclass[]{article}

\makeatletter
\newcommand\leftalignline[1]{\@@line{#1\hss}}
\newcommand\rightalignline[1]{\@@line{\hss#1}}
\makeatother

\begin{document}
\hsize=5cm % just so that line breaks are a bit earlier
This is some longish text that is long and needs me to centre some
material\\
\centerline{here is center}
Also I'd like to display some stuff to the left\\
\leftalignline{here is left}
and to put something on the right\\
\rightalignline{here is right.}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보