Why text-align:justify is making a large line space and how to correct them? - space

I'm writing a blog website and want to make the paragraph with text-align justified. However, It worked fine. However, there are also of white space between letters sometimes. Is there any way to correct it?

Related

Adjust white fill between paragraphs in LaTeX

Latex seems to fill in white space between the paragraphs by default, to get every page to end at approx the same height (at least with the book and scrreprt class). This is all fine, but I have a couple of pages with only two paragraphs. Latex insists on putting in 2cm of white space between them, which looks bad. I know that I can use \raggedrift for the whole document, but I kind of like the white fill except for the pages with only two paragraphs. I have also tried to adjust manually with \vspace{-1cm}, but it doesn't seem to work.
Is there a way to set a maximum value to the height of white fill between paragraphs?
If your mostly-empty pages are because the following content starts on a new page (at the end of a chapter, for example), then the easiest way to fix it is probably to insert a vertical fill after your last paragraph. The vertical fill should expand to occupy the extra space, keeping the inter-paragraph fill small.
You can change the vertical space applied to every paragraph by setting the value of \parskip.
The solution is very simple. At the end of the last paragraph of the page, add '\vfill'. This will fill up the rest of the page, making the two paragraphs on it move as close to each other as they would normally.
I just tested it myself and it works.

Character spacing in LaTeX with lstlisting package

I'm trying to get my code snippets to look as good as possible and so far I'm having troubles with the character spacing. Here is an example of the output:
alt text http://grab.by/grabs/2bb230de7c088d007733f52b95a40363.png
While the text in small is perfect, all the keywords that are in capital letters look terrible. Here are the settings I use
\lstset{basicstyle=\footnotesize, basewidth=0.5em}
If I increase the basewidth, the capital letters look good, but I can't get any decent sized line of code in one line. The following example does not fit in a page and I already put two line breaks in:
alt text http://grab.by/grabs/97ec29aa5a6811ce28bcd30bd389b52f.png
Does anyone have a clue how I can get this to work? Using \ttfamily does the trick, however, I'd prefer keeping the font.
Thanks.
If you prioritize looking nice, then using flexible colums is preferable:
\lstset{basicstyle=\footnotesize, columns=fullflexible}
You "obviously" need to scale the capital letters down horizontally. I do not know of a way to do this without actually editing the font itself.
However, you could put the entire listing into a \scalebox resp. \resizebox (from the graphicx package).
On a side note, the font you are using seems a bit strange, though, since the distance between small letters is significantly bigger than that between capital letters.

dealing with large figures in Latex

I have a large figure that appears at the end of my document rather than in the section that I want to be in. Even \begin{figure}[h] doesn't help. Without scaling it down, how can I put it at the end of the section I want it in?
Using the afterpage package can be a good solution. However, using the option here you are trying to tell LaTeX where you want to put the image. Instead, you need to tell LaTeX where the image is good to be put:
use \begin{figure}[tb] for figures that fit well in a page with text (say, half of the text height for the figure and the other half for the text)
use \begin{figure}[p] for floats large enough to require a dedicated page.
Setting a proper option increase your chances to have the image almost where you want, having at the same time a good page layout.
If the figure is still too far from the page where it should be placed, you can set some "barriers" for floats positioning with the packages placeins or afterpage (already mentioned).
Here is a small tutorial for float placement. The thing you want to do is put an \afterpage{\clearpage} command at the end of the section. This will create an additional page after the current one and place the floats that are left in the queque there. If the float still doesn't get placed, you have to resize it. If you really don't want to resize it and it should fit on the page, then you could try changing the margins and text area temporarily (i.e. just for that one page) and see if that lets the float get placed.
i forget if it's the float or array package that provides this, but,
\begin{figure}[H]
...
\end{figure}
The upper case H will put the figure exactly where it is in your code.

How to fully justify texts programmatically (Delphi)?

How can I fully justify a block of text (like MS Word does, not only on the right and not only on the left but on both sides)?
I want to justify some texts (mainly arabic text) adjusted to certain screen size (some handheld device screen actually, and its text viewer doesn't have this function) and save this text as justified. So I can reload and reuse it again elsewhere.
(The problem with MS word is, that if you copy the justified text from MS Word and paste it to another editor it'll copy it un-justified).
Update : for now I'm thinking of doing it like this:
get-a-word
get-word-width
add-word-to-total-Word and add-Word-width-to-total-word-width
check if total-Word-width = myscreen-width then continue
else if total-Word-width is between myscree-wdith and (myscreen-width -3) then
add-spaces-To-total-word until it = myscreen-width
This is what I'm thinking now, but I put this question up and hope to see if there is a better solution, or somebody else already implemented it.
PS: I hope I have made my question clear and I'm sorry for bad expression if there is.
edit1 : changed the title to make it more clear.
If you want to justify plain text, you can only add extra spaces to the lines to get them align on the left and right. Unfortunately the character widths differ in fonts; so doing it this way will only work for a certain font, unless you limit yourself to monospaced fonts where all characters have the same size.
If you want a result like in Word, adding spaces won't cut it. Word will not add spaces, but stretch and shrink the existing spaces. This information is lost when you copy and paste it into another app.
Either way, justifying is an optimization problem. If you are interested in a good solution and its implementation: have a look a TeX. For an implementation that works on plain text with monospaced fonts have a look at par
There are some API calls that may help:
ExtTextOut and GetCharacterPlacement
Look at the GCP_JUSTIFY flag for GetCharacterPlacement
ExtTextOut is used by Canvas.TextRect
The problem you are going to face is always going to be differences in the rendering of the font. Word handles full justification by adjusting kerning as well as adjusting the number of pixels between words by a few (either way). The end result is lined up both margins. This pixel adjustment is done BOTH ways, and as evenly as possible.
To properly handle this in your portable device you will have to also perform the same algorithm for the display of the text there.
If this is not possible, then the ONLY way you can even get somewhat close would be to add whitespace between words.
As has been pointed out in other answers Word does full justification by stretching the existing spaces often by very small amounts. This is only possible if you have full control over how your text is drawn on the screen (which word - or any other windows program has).
You only real option in this regard would be to implement your own text viewer on the platform you are targeting. Eg you would need to draw the text on the screen yourself (any platform that allows games should allow you to draw on the screen). However this seems like an awful lot of trouble to get justified text.
Sorry couldn't be of more help.

vertical edge setting

What column setting do you use in the IDE for the vertical edge. I use 80 columns in line mode, but I wanted to know if this is common or is there a more common standard? I have seen other options like background mode, but found it too distracting.
Vertical Edge, for those who are unfamiliar, is a line or an area which marks off the section where the code can be written. Anything beyond may not format the best way in other code readers or makes code readability tougher. Please correct if my understanding is inaccurate.
Widescreen monitors and a preference for a smaller font so I get more vertical lines makes 80 a little lacking on the wide side.
I don't have a vertical column setting. Any coding lines (usually ifs) that may be too wide, I split at logical operators. For text lines, its a bit more nebulous where I actually split them but split them conservative.
Note: Your question appears to be the same as: https://stackoverflow.com/questions/903754/do-you-still-limit-line-length-in-code and question 746853 (which I can't hyperlink to as I am a "new user")

Resources